Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dependencies): bump Souin v1.6.49 #83

Merged
merged 1 commit into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 26 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ This is a distributed HTTP cache module for Caddy based on [Souin](https://githu
Using the minimal configuration the responses will be cached for `120s`
```caddy
{
order cache before rewrite
cache
}

Expand All @@ -29,7 +28,6 @@ example.com {
Here are all the available options for the global options
```caddy
{
order cache before rewrite
log {
level debug
}
Expand Down Expand Up @@ -324,9 +322,24 @@ redis-configuration.com {
cache {
redis {
configuration {
ClientName souin-redis
InitAddress 127.0.0.1:6379
SelectDB 0
Network my-network
Addr 127.0.0.1:6379
Username user
Password password
DB 1
MaxRetries 1
MinRetryBackoff 5s
MaxRetryBackoff 5s
DialTimeout 5s
ReadTimeout 5s
WriteTimeout 5s
PoolFIFO true
PoolSize 99999
PoolTimeout 10s
MinIdleConns 100
MaxIdleConns 100
ConnMaxIdleTime 5s
ConnMaxLifetime 5s
}
}
}
Expand Down Expand Up @@ -370,8 +383,12 @@ What does these directives mean?
| `key.disable_host` | Disable the host part in the key | `true`<br/><br/>`(default: false)` |
| `key.disable_method` | Disable the method part in the key | `true`<br/><br/>`(default: false)` |
| `key.disable_query` | Disable the query string part in the key | `true`<br/><br/>`(default: false)` |
| `key.disable_scheme` | Disable the scheme string part in the key | `true`<br/><br/>`(default: false)` |
| `key.hash` | Hash the key before store it in the storage to get smaller keys | `true`<br/><br/>`(default: false)` |
| `key.headers` | Add headers to the key matching the regexp | `Authorization Content-Type X-Additional-Header` |
| `key.hide` | Prevent the key from being exposed in the `Cache-Status` HTTP response header | `true`<br/><br/>`(default: false)` |
| `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}` |
| `max_cacheable_body_bytes` | Set the maximum size (in bytes) for a response body to be cached (unlimited if omited) | `1048576` (1MB) |
| `mode` | Bypass the RFC respect | One of `bypass` `bypass_request` `bypass_response` `strict` (default `strict`) |
| `nuts` | Configure the Nuts cache storage | |
| `nuts.path` | Set the Nuts file path storage | `/anywhere/nuts/storage` |
Expand All @@ -381,11 +398,15 @@ What does these directives mean?
| `olric` | Configure the Olric cache storage | |
| `olric.path` | Configure Olric with a file | `/anywhere/olric_configuration.json` |
| `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/) |
| `otter` | Configure the Otter cache storage | |
| `otter.configuration` | Configure Otter directly in the Caddyfile or your JSON caddy configuration | |
| `otter.configuration.size` | Set the size of the pool in Otter | `999999` (default `10000`) |
| `redis` | Configure the Redis cache storage | |
| `redis.url` | Set the Redis url storage | `localhost:6379` |
| `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) |
| `regex.exclude` | The regex used to prevent paths being cached | `^[A-z]+.*$` |
| `stale` | The stale duration | `25m` |
| `storers` | Storers chain to fallback if a previous one is unreachable or don't have the resource | `otter nuts badger redis` |
| `timeout` | The timeout configuration | |
| `timeout.backend` | The timeout duration to consider the backend as unreachable | `10s` |
| `timeout.cache` | The timeout duration to consider the cache provider as unreachable | `10ms` |
Expand Down
4 changes: 2 additions & 2 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ func (s SouinApp) CaddyModule() caddy.ModuleInfo {
}

var (
_ caddy.App = (*SouinApp)(nil)
_ caddy.Module = (*SouinApp)(nil)
_ caddy.App = (*SouinApp)(nil)
_ caddy.Module = (*SouinApp)(nil)
)
42 changes: 39 additions & 3 deletions configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type DefaultCache struct {
// The default Cache-Control header value if none set by the upstream server.
DefaultCacheControl string `json:"default_cache_control"`
// The maximum body size (in bytes) to be stored into cache.
MaxBodyBytes uint64 `json:"max_cachable_body_bytes"`
MaxBodyBytes uint64 `json:"max_cacheable_body_bytes"`
// Redis provider configuration.
Distributed bool `json:"distributed"`
// Headers to add to the cache key if they are present.
Expand All @@ -40,6 +40,8 @@ type DefaultCache struct {
Etcd configurationtypes.CacheProvider `json:"etcd"`
// NutsDB provider configuration.
Nuts configurationtypes.CacheProvider `json:"nuts"`
// Otter provider configuration.
Otter configurationtypes.CacheProvider `json:"otter"`
// Regex to exclude cache.
Regex configurationtypes.Regex `json:"regex"`
// Storage providers chaining and order.
Expand Down Expand Up @@ -102,6 +104,11 @@ func (d *DefaultCache) GetNuts() configurationtypes.CacheProvider {
return d.Nuts
}

// GetOtter returns otter configuration
func (d *DefaultCache) GetOtter() configurationtypes.CacheProvider {
return d.Otter
}

// GetOlric returns olric configuration
func (d *DefaultCache) GetOlric() configurationtypes.CacheProvider {
return d.Olric
Expand Down Expand Up @@ -169,6 +176,11 @@ func (c *Configuration) GetUrls() map[string]configurationtypes.URL {
return c.URLs
}

// GetDefaultCache get the default cache
func (c *Configuration) GetPluginName() string {
return "caddy"
}

// GetDefaultCache get the default cache
func (c *Configuration) GetDefaultCache() configurationtypes.DefaultCacheInterface {
return &c.DefaultCache
Expand Down Expand Up @@ -373,6 +385,12 @@ func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isGlobal boo
ck.DisableMethod = true
case "disable_query":
ck.DisableQuery = true
case "disable_scheme":
ck.DisableScheme = true
case "template":
ck.Template = h.RemainingArgs()[0]
case "hash":
ck.Hash = true
case "hide":
ck.Hide = true
case "headers":
Expand Down Expand Up @@ -419,11 +437,11 @@ func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isGlobal boo
case "default_cache_control":
args := h.RemainingArgs()
cfg.DefaultCache.DefaultCacheControl = strings.Join(args, " ")
case "max_cachable_body_bytes":
case "max_cacheable_body_bytes":
args := h.RemainingArgs()
maxBodyBytes, err := strconv.ParseUint(args[0], 10, 64)
if err != nil {
return h.Errf("unsupported max_cachable_body_bytes: %s", args)
return h.Errf("unsupported max_cacheable_body_bytes: %s", args)
} else {
cfg.DefaultCache.MaxBodyBytes = maxBodyBytes
}
Expand Down Expand Up @@ -455,6 +473,12 @@ func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isGlobal boo
config_key.DisableMethod = true
case "disable_query":
config_key.DisableQuery = true
case "disable_scheme":
config_key.DisableScheme = true
case "template":
config_key.Template = h.RemainingArgs()[0]
case "hash":
config_key.Hash = true
case "hide":
config_key.Hide = true
case "headers":
Expand Down Expand Up @@ -491,6 +515,18 @@ func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isGlobal boo
}
}
cfg.DefaultCache.Nuts = provider
case "otter":
provider := configurationtypes.CacheProvider{}
for nesting := h.Nesting(); h.NextBlock(nesting); {
directive := h.Val()
switch directive {
case "configuration":
provider.Configuration = parseCaddyfileRecursively(h)
default:
return h.Errf("unsupported otter directive: %s", directive)
}
}
cfg.DefaultCache.Otter = provider
case "olric":
cfg.DefaultCache.Distributed = true
provider := configurationtypes.CacheProvider{}
Expand Down
Loading
Loading