Skip to content

Commit 1dd8d3b

Browse files
authored
feat(dependencies): bump Souin v1.6.49 (#83)
1 parent 3d544e3 commit 1dd8d3b

File tree

7 files changed

+548
-447
lines changed

7 files changed

+548
-447
lines changed

README.md

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ This is a distributed HTTP cache module for Caddy based on [Souin](https://githu
1515
Using the minimal configuration the responses will be cached for `120s`
1616
```caddy
1717
{
18-
order cache before rewrite
1918
cache
2019
}
2120
@@ -29,7 +28,6 @@ example.com {
2928
Here are all the available options for the global options
3029
```caddy
3130
{
32-
order cache before rewrite
3331
log {
3432
level debug
3533
}
@@ -324,9 +322,24 @@ redis-configuration.com {
324322
cache {
325323
redis {
326324
configuration {
327-
ClientName souin-redis
328-
InitAddress 127.0.0.1:6379
329-
SelectDB 0
325+
Network my-network
326+
Addr 127.0.0.1:6379
327+
Username user
328+
Password password
329+
DB 1
330+
MaxRetries 1
331+
MinRetryBackoff 5s
332+
MaxRetryBackoff 5s
333+
DialTimeout 5s
334+
ReadTimeout 5s
335+
WriteTimeout 5s
336+
PoolFIFO true
337+
PoolSize 99999
338+
PoolTimeout 10s
339+
MinIdleConns 100
340+
MaxIdleConns 100
341+
ConnMaxIdleTime 5s
342+
ConnMaxLifetime 5s
330343
}
331344
}
332345
}
@@ -370,8 +383,12 @@ What does these directives mean?
370383
| `key.disable_host` | Disable the host part in the key | `true`<br/><br/>`(default: false)` |
371384
| `key.disable_method` | Disable the method part in the key | `true`<br/><br/>`(default: false)` |
372385
| `key.disable_query` | Disable the query string part in the key | `true`<br/><br/>`(default: false)` |
386+
| `key.disable_scheme` | Disable the scheme string part in the key | `true`<br/><br/>`(default: false)` |
387+
| `key.hash` | Hash the key before store it in the storage to get smaller keys | `true`<br/><br/>`(default: false)` |
373388
| `key.headers` | Add headers to the key matching the regexp | `Authorization Content-Type X-Additional-Header` |
374389
| `key.hide` | Prevent the key from being exposed in the `Cache-Status` HTTP response header | `true`<br/><br/>`(default: false)` |
390+
| `key.template` | Use caddy templates to create the key (when this option is enabled, disable_* directives are skipped) | `KEY-{http.request.uri.path}-{http.request.uri.query}` |
391+
| `max_cacheable_body_bytes` | Set the maximum size (in bytes) for a response body to be cached (unlimited if omited) | `1048576` (1MB) |
375392
| `mode` | Bypass the RFC respect | One of `bypass` `bypass_request` `bypass_response` `strict` (default `strict`) |
376393
| `nuts` | Configure the Nuts cache storage | |
377394
| `nuts.path` | Set the Nuts file path storage | `/anywhere/nuts/storage` |
@@ -381,11 +398,15 @@ What does these directives mean?
381398
| `olric` | Configure the Olric cache storage | |
382399
| `olric.path` | Configure Olric with a file | `/anywhere/olric_configuration.json` |
383400
| `olric.configuration` | Configure Olric directly in the Caddyfile or your JSON caddy configuration | [See the Olric configuration for the options](https://github.com/buraksezer/olric/blob/master/cmd/olricd/olricd.yaml/) |
401+
| `otter` | Configure the Otter cache storage | |
402+
| `otter.configuration` | Configure Otter directly in the Caddyfile or your JSON caddy configuration | |
403+
| `otter.configuration.size` | Set the size of the pool in Otter | `999999` (default `10000`) |
384404
| `redis` | Configure the Redis cache storage | |
385405
| `redis.url` | Set the Redis url storage | `localhost:6379` |
386406
| `redis.configuration` | Configure Redis directly in the Caddyfile or your JSON caddy configuration | [See the Nuts configuration for the options](https://github.com/nutsdb/nutsdb#default-options) |
387407
| `regex.exclude` | The regex used to prevent paths being cached | `^[A-z]+.*$` |
388408
| `stale` | The stale duration | `25m` |
409+
| `storers` | Storers chain to fallback if a previous one is unreachable or don't have the resource | `otter nuts badger redis` |
389410
| `timeout` | The timeout configuration | |
390411
| `timeout.backend` | The timeout duration to consider the backend as unreachable | `10s` |
391412
| `timeout.cache` | The timeout duration to consider the cache provider as unreachable | `10ms` |

app.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,6 @@ func (s SouinApp) CaddyModule() caddy.ModuleInfo {
5252
}
5353

5454
var (
55-
_ caddy.App = (*SouinApp)(nil)
56-
_ caddy.Module = (*SouinApp)(nil)
55+
_ caddy.App = (*SouinApp)(nil)
56+
_ caddy.Module = (*SouinApp)(nil)
5757
)

configuration.go

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type DefaultCache struct {
2323
// The default Cache-Control header value if none set by the upstream server.
2424
DefaultCacheControl string `json:"default_cache_control"`
2525
// The maximum body size (in bytes) to be stored into cache.
26-
MaxBodyBytes uint64 `json:"max_cachable_body_bytes"`
26+
MaxBodyBytes uint64 `json:"max_cacheable_body_bytes"`
2727
// Redis provider configuration.
2828
Distributed bool `json:"distributed"`
2929
// Headers to add to the cache key if they are present.
@@ -40,6 +40,8 @@ type DefaultCache struct {
4040
Etcd configurationtypes.CacheProvider `json:"etcd"`
4141
// NutsDB provider configuration.
4242
Nuts configurationtypes.CacheProvider `json:"nuts"`
43+
// Otter provider configuration.
44+
Otter configurationtypes.CacheProvider `json:"otter"`
4345
// Regex to exclude cache.
4446
Regex configurationtypes.Regex `json:"regex"`
4547
// Storage providers chaining and order.
@@ -102,6 +104,11 @@ func (d *DefaultCache) GetNuts() configurationtypes.CacheProvider {
102104
return d.Nuts
103105
}
104106

107+
// GetOtter returns otter configuration
108+
func (d *DefaultCache) GetOtter() configurationtypes.CacheProvider {
109+
return d.Otter
110+
}
111+
105112
// GetOlric returns olric configuration
106113
func (d *DefaultCache) GetOlric() configurationtypes.CacheProvider {
107114
return d.Olric
@@ -169,6 +176,11 @@ func (c *Configuration) GetUrls() map[string]configurationtypes.URL {
169176
return c.URLs
170177
}
171178

179+
// GetDefaultCache get the default cache
180+
func (c *Configuration) GetPluginName() string {
181+
return "caddy"
182+
}
183+
172184
// GetDefaultCache get the default cache
173185
func (c *Configuration) GetDefaultCache() configurationtypes.DefaultCacheInterface {
174186
return &c.DefaultCache
@@ -373,6 +385,12 @@ func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isGlobal boo
373385
ck.DisableMethod = true
374386
case "disable_query":
375387
ck.DisableQuery = true
388+
case "disable_scheme":
389+
ck.DisableScheme = true
390+
case "template":
391+
ck.Template = h.RemainingArgs()[0]
392+
case "hash":
393+
ck.Hash = true
376394
case "hide":
377395
ck.Hide = true
378396
case "headers":
@@ -419,11 +437,11 @@ func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isGlobal boo
419437
case "default_cache_control":
420438
args := h.RemainingArgs()
421439
cfg.DefaultCache.DefaultCacheControl = strings.Join(args, " ")
422-
case "max_cachable_body_bytes":
440+
case "max_cacheable_body_bytes":
423441
args := h.RemainingArgs()
424442
maxBodyBytes, err := strconv.ParseUint(args[0], 10, 64)
425443
if err != nil {
426-
return h.Errf("unsupported max_cachable_body_bytes: %s", args)
444+
return h.Errf("unsupported max_cacheable_body_bytes: %s", args)
427445
} else {
428446
cfg.DefaultCache.MaxBodyBytes = maxBodyBytes
429447
}
@@ -455,6 +473,12 @@ func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isGlobal boo
455473
config_key.DisableMethod = true
456474
case "disable_query":
457475
config_key.DisableQuery = true
476+
case "disable_scheme":
477+
config_key.DisableScheme = true
478+
case "template":
479+
config_key.Template = h.RemainingArgs()[0]
480+
case "hash":
481+
config_key.Hash = true
458482
case "hide":
459483
config_key.Hide = true
460484
case "headers":
@@ -491,6 +515,18 @@ func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isGlobal boo
491515
}
492516
}
493517
cfg.DefaultCache.Nuts = provider
518+
case "otter":
519+
provider := configurationtypes.CacheProvider{}
520+
for nesting := h.Nesting(); h.NextBlock(nesting); {
521+
directive := h.Val()
522+
switch directive {
523+
case "configuration":
524+
provider.Configuration = parseCaddyfileRecursively(h)
525+
default:
526+
return h.Errf("unsupported otter directive: %s", directive)
527+
}
528+
}
529+
cfg.DefaultCache.Otter = provider
494530
case "olric":
495531
cfg.DefaultCache.Distributed = true
496532
provider := configurationtypes.CacheProvider{}

0 commit comments

Comments
 (0)