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(storers): Add a new NutsMemcached storage backend built on NutsDB #452

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
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
7 changes: 7 additions & 0 deletions configurationtypes/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ type DefaultCache struct {
Etcd CacheProvider `json:"etcd" yaml:"etcd"`
Mode string `json:"mode" yaml:"mode"`
Nuts CacheProvider `json:"nuts" yaml:"nuts"`
NutsMemcached CacheProvider `json:"nuts_memcached" yaml:"nuts_memcached"`
Olric CacheProvider `json:"olric" yaml:"olric"`
Otter CacheProvider `json:"otter" yaml:"otter"`
Redis CacheProvider `json:"redis" yaml:"redis"`
Expand Down Expand Up @@ -300,6 +301,11 @@ func (d *DefaultCache) GetOtter() CacheProvider {
return d.Otter
}

// GetNutsMemcached returns nuts_memcached configuration
func (d *DefaultCache) GetNutsMemcached() CacheProvider {
return d.NutsMemcached
}

// GetOlric returns olric configuration
func (d *DefaultCache) GetOlric() CacheProvider {
return d.Olric
Expand Down Expand Up @@ -356,6 +362,7 @@ type DefaultCacheInterface interface {
GetMode() string
GetOtter() CacheProvider
GetNuts() CacheProvider
GetNutsMemcached() CacheProvider
GetOlric() CacheProvider
GetRedis() CacheProvider
GetHeaders() []string
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/darkweak/souin
go 1.21

require (
github.com/bradfitz/gomemcache v0.0.0-20230905024940-24af94b03874
github.com/buraksezer/olric v0.5.4
github.com/cespare/xxhash/v2 v2.2.0
github.com/dgraph-io/badger/v3 v3.2103.5
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kB
github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA=
github.com/bits-and-blooms/bitset v1.5.0 h1:NpE8frKRLGHIcEzkR+gZhiioW1+WbYV6fKwD6ZIpQT8=
github.com/bits-and-blooms/bitset v1.5.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA=
github.com/bradfitz/gomemcache v0.0.0-20230905024940-24af94b03874 h1:N7oVaKyGp8bttX0bfZGmcGkjz7DLQXhAn3DNd3T0ous=
github.com/bradfitz/gomemcache v0.0.0-20230905024940-24af94b03874/go.mod h1:r5xuitiExdLAJ09PR7vBVENGvp4ZuTBeWTGtxuX3K+c=
github.com/buraksezer/consistent v0.10.0 h1:hqBgz1PvNLC5rkWcEBVAL9dFMBWz6I0VgUCW25rrZlU=
github.com/buraksezer/consistent v0.10.0/go.mod h1:6BrVajWq7wbKZlTOUPs/XVfR8c0maujuPowduSpZqmw=
github.com/buraksezer/olric v0.5.4 h1:LDgLIfVoyol4qzdNirrrDUKqzFw0yDsa7ukvLrpP4cU=
Expand Down
13 changes: 7 additions & 6 deletions pkg/api/souin.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,13 @@ func (s *SouinAPI) listKeys(search string) []string {
}

var storageToInfiniteTTLMap = map[string]time.Duration{
"BADGER": 365 * 24 * time.Hour,
"ETCD": 365 * 24 * time.Hour,
"NUTS": 0,
"OLRIC": 365 * 24 * time.Hour,
"OTTER": 365 * 24 * time.Hour,
"REDIS": 0,
"BADGER": 365 * 24 * time.Hour,
"ETCD": 365 * 24 * time.Hour,
"NUTS": 0,
"NUTS_MEMCACHED": 0,
"OLRIC": 365 * 24 * time.Hour,
"OTTER": 365 * 24 * time.Hour,
"REDIS": 0,
}

func (s *SouinAPI) purgeMapping() {
Expand Down
Loading
Loading