Skip to content

Commit

Permalink
feat(global): implement simplefs storage & add missing cdn props support
Browse files Browse the repository at this point in the history
  • Loading branch information
darkweak committed Oct 22, 2024
1 parent 6cc4ae5 commit fd917e6
Show file tree
Hide file tree
Showing 14 changed files with 262 additions and 365 deletions.
9 changes: 8 additions & 1 deletion configurationtypes/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ type DefaultCache struct {
Redis CacheProvider `json:"redis" yaml:"redis"`
Port Port `json:"port" yaml:"port"`
Regex Regex `json:"regex" yaml:"regex"`
SimpleFS CacheProvider `json:"simplefs" yaml:"simplefs"`
Stale Duration `json:"stale" yaml:"stale"`
Storers []string `json:"storers" yaml:"storers"`
Timeout Timeout `json:"timeout" yaml:"timeout"`
Expand Down Expand Up @@ -300,7 +301,7 @@ func (d *DefaultCache) GetMode() string {
return d.Mode
}

// GetNats returns nuts configuration
// GetNats returns nats configuration
func (d *DefaultCache) GetNats() CacheProvider {
return d.Nats
}
Expand Down Expand Up @@ -340,6 +341,11 @@ func (d *DefaultCache) GetTTL() time.Duration {
return d.TTL.Duration
}

// GetSimpleFS returns simplefs configuration
func (d *DefaultCache) GetSimpleFS() CacheProvider {
return d.SimpleFS
}

// GetStale returns the stale duration
func (d *DefaultCache) GetStale() time.Duration {
return d.Stale.Duration
Expand Down Expand Up @@ -382,6 +388,7 @@ type DefaultCacheInterface interface {
GetHeaders() []string
GetKey() Key
GetRegex() Regex
GetSimpleFS() CacheProvider
GetStale() time.Duration
GetStorers() []string
GetTimeout() Timeout
Expand Down
1 change: 1 addition & 0 deletions pkg/api/souin.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ var storageToInfiniteTTLMap = map[string]time.Duration{
"OLRIC": types.OneYearDuration,
"OTTER": types.OneYearDuration,
"REDIS": -1,
"SIMPLEFS": 0,
types.DefaultStorageName: types.OneYearDuration,
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/middleware/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func NewHTTPCacheHandler(c configurationtypes.AbstractConfigurationInterface) *S
storers := []types.Storer{}
if len(storedStorers) != 0 {
dc := c.GetDefaultCache()
for _, s := range []string{dc.GetBadger().Uuid, dc.GetEtcd().Uuid, dc.GetNats().Uuid, dc.GetNuts().Uuid, dc.GetOlric().Uuid, dc.GetOtter().Uuid, dc.GetRedis().Uuid} {
for _, s := range []string{dc.GetBadger().Uuid, dc.GetEtcd().Uuid, dc.GetNats().Uuid, dc.GetNuts().Uuid, dc.GetOlric().Uuid, dc.GetOtter().Uuid, dc.GetRedis().Uuid, dc.GetSimpleFS().Uuid} {
if s != "" {
if st := core.GetRegisteredStorer(s); st != nil {
storers = append(storers, st.(types.Storer))
Expand Down
1 change: 1 addition & 0 deletions pkg/surrogate/providers/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ var storageToInfiniteTTLMap = map[string]time.Duration{
"OLRIC": types.OneYearDuration,
"OTTER": types.OneYearDuration,
"REDIS": -1,
"SIMPLEFS": 0,
types.DefaultStorageName: types.OneYearDuration,
}

Expand Down
Loading

0 comments on commit fd917e6

Please sign in to comment.