Documentation ¶
Index ¶
- Variables
- type Backend
- type BackendConfig
- type Entry
- type FactoryConfig
- type Frontend
- type FrontendFactory
- func (f *FrontendFactory) BindConfiguredCaches(injector *dingo.Injector) error
- func (f *FrontendFactory) BuildBackend(backendConfig BackendConfig, frontendName string) (Backend, error)
- func (f *FrontendFactory) BuildWithBackend(backend Backend) *Frontend
- func (f *FrontendFactory) Inject(provider FrontendProvider, redisBackendFactory *RedisBackendFactory, ...) *FrontendFactory
- func (f *FrontendFactory) NewMemoryBackend(config MemoryBackendConfig, frontendName string) (Backend, error)
- func (f *FrontendFactory) NewRedisBackend(config RedisBackendConfig, frontendName string) (Backend, error)
- func (f *FrontendFactory) NewTwoLevel(config TwoLevelBackendConfig) (Backend, error)
- type FrontendProvider
- type HTTPLoader
- type InMemoryBackendFactory
- func (f *InMemoryBackendFactory) Build() (Backend, error)
- func (f *InMemoryBackendFactory) SetConfig(config MemoryBackendConfig) *InMemoryBackendFactory
- func (f *InMemoryBackendFactory) SetFrontendName(frontendName string) *InMemoryBackendFactory
- func (f *InMemoryBackendFactory) SetLurkerPeriod(period time.Duration) *InMemoryBackendFactory
- type MemoryBackend
- type MemoryBackendConfig
- type Meta
- type Metrics
- type MetricsBackend
- type Module
- type RedisBackend
- func (b *RedisBackend) Flush() error
- func (b *RedisBackend) Get(key string) (entry Entry, found bool)
- func (b *RedisBackend) Purge(key string) error
- func (b *RedisBackend) PurgeTags(tags []string) error
- func (b *RedisBackend) Set(key string, entry Entry) error
- func (b *RedisBackend) Status() (bool, string)
- type RedisBackendConfig
- type RedisBackendFactory
- func (f *RedisBackendFactory) Build() (Backend, error)
- func (f *RedisBackendFactory) Inject(logger flamingo.Logger) *RedisBackendFactory
- func (f *RedisBackendFactory) SetConfig(config RedisBackendConfig) *RedisBackendFactory
- func (f *RedisBackendFactory) SetFrontendName(frontendName string) *RedisBackendFactory
- func (f *RedisBackendFactory) SetPool(pool *redis.Pool) *RedisBackendFactory
- type TagSupporting
- type TwoLevelBackend
- type TwoLevelBackendConfig
- type TwoLevelBackendFactory
Constants ¶
This section is empty.
Variables ¶
var ( ErrAllBackendsFailed = errors.New("all backends failed") ErrAtLeastOneBackendFailed = errors.New("at least one backends failed") )
var ErrInvalidBackend = errors.New("invalid backend supplied")
var ErrInvalidEntry = errors.New("cache returned invalid entry type")
var (
ErrInvalidRedisConfig = errors.New("invalid redis config")
)
var ErrMemoryConfig = errors.New("memory config not complete")
var ErrNoCacheBackend = errors.New("no backend defined")
var ErrRedisConfig = errors.New("redis config not complete")
var ErrTwoLevelConfig = errors.New("twolevel config not complete")
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface { Get(key string) (Entry, bool) Set(key string, entry Entry) error Purge(key string) error Flush() error }
Backend to persist cache data
type BackendConfig ¶
type BackendConfig struct { BackendType string Memory *MemoryBackendConfig Redis *RedisBackendConfig Twolevel *struct { First *BackendConfig Second *BackendConfig } }
BackendConfig typed configuration used to build BackendCaches by the factory
type FactoryConfig ¶
type FactoryConfig map[string]BackendConfig
FactoryConfig typed configuration used to build Caches by the factory
type Frontend ¶
type Frontend struct { singleflight.Group // contains filtered or unexported fields }
Frontend caches and delivers HTTP responses
func (*Frontend) Get ¶
Get the cached response if possible or perform a call to loader The result of loader will be returned and cached
func (*Frontend) SetBackend ¶
SetBackend for usage
type FrontendFactory ¶
type FrontendFactory struct {
// contains filtered or unexported fields
}
FrontendFactory that can be used to build caches
func (*FrontendFactory) BindConfiguredCaches ¶
func (f *FrontendFactory) BindConfiguredCaches(injector *dingo.Injector) error
BindConfiguredCaches creates annotated bindings from the cache configuration
func (*FrontendFactory) BuildBackend ¶
func (f *FrontendFactory) BuildBackend(backendConfig BackendConfig, frontendName string) (Backend, error)
BuildBackend by given BackendConfig and frontendName
func (*FrontendFactory) BuildWithBackend ¶
func (f *FrontendFactory) BuildWithBackend(backend Backend) *Frontend
BuildWithBackend returns new HTTPFrontend cache with given backend
func (*FrontendFactory) Inject ¶
func (f *FrontendFactory) Inject( provider FrontendProvider, redisBackendFactory *RedisBackendFactory, inMemoryBackendFactory *InMemoryBackendFactory, twoLevelBackendFactory *TwoLevelBackendFactory, cfg *struct { CacheConfig config.Map `inject:"config:httpcache.frontendFactory,optional"` }, ) *FrontendFactory
Inject for dependencies
func (*FrontendFactory) NewMemoryBackend ¶
func (f *FrontendFactory) NewMemoryBackend(config MemoryBackendConfig, frontendName string) (Backend, error)
NewMemoryBackend with given config and name
func (*FrontendFactory) NewRedisBackend ¶
func (f *FrontendFactory) NewRedisBackend(config RedisBackendConfig, frontendName string) (Backend, error)
NewRedisBackend with given config and name
func (*FrontendFactory) NewTwoLevel ¶
func (f *FrontendFactory) NewTwoLevel(config TwoLevelBackendConfig) (Backend, error)
NewTwoLevel with given config
type FrontendProvider ¶
type FrontendProvider func() *Frontend
FrontendProvider - Dingo Provider func
type HTTPLoader ¶
HTTPLoader returns an Entry to be cached. All Entries will be cached if error is nil
type InMemoryBackendFactory ¶
type InMemoryBackendFactory struct {
// contains filtered or unexported fields
}
InMemoryBackendFactory factory
func (*InMemoryBackendFactory) Build ¶
func (f *InMemoryBackendFactory) Build() (Backend, error)
Build the instance
func (*InMemoryBackendFactory) SetConfig ¶
func (f *InMemoryBackendFactory) SetConfig(config MemoryBackendConfig) *InMemoryBackendFactory
SetConfig for factory
func (*InMemoryBackendFactory) SetFrontendName ¶
func (f *InMemoryBackendFactory) SetFrontendName(frontendName string) *InMemoryBackendFactory
SetFrontendName used in Metrics
func (*InMemoryBackendFactory) SetLurkerPeriod ¶ added in v0.3.1
func (f *InMemoryBackendFactory) SetLurkerPeriod(period time.Duration) *InMemoryBackendFactory
SetLurkerPeriod sets the timeframe how often expired cache entries should be checked/cleaned up, if 0 is provided the default period of 1 minute is taken
type MemoryBackend ¶
type MemoryBackend struct {
// contains filtered or unexported fields
}
MemoryBackend implements the cache backend interface with an "in memory" solution
func (*MemoryBackend) Flush ¶
func (m *MemoryBackend) Flush() error
Flush purges all entries in the cache
func (*MemoryBackend) Get ¶
func (m *MemoryBackend) Get(key string) (Entry, bool)
Get tries to get an object from cache
func (*MemoryBackend) Set ¶
func (m *MemoryBackend) Set(key string, entry Entry) error
Set a cache entry with a key
func (*MemoryBackend) SetSize ¶
func (m *MemoryBackend) SetSize(size int) error
SetSize creates a new underlying cache of the given size
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics take care of publishing metrics for a specific cache
func NewCacheMetrics ¶
NewCacheMetrics creates a backend metrics helper instance
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module basic struct
func (*Module) Inject ¶
func (m *Module) Inject( frontendFactory *FrontendFactory, ) *Module
Inject dependencies
type RedisBackend ¶
type RedisBackend struct {
// contains filtered or unexported fields
}
RedisBackend implements the cache backend interface with a redis solution
func (*RedisBackend) Get ¶
func (b *RedisBackend) Get(key string) (entry Entry, found bool)
Get a cache key
func (*RedisBackend) PurgeTags ¶
func (b *RedisBackend) PurgeTags(tags []string) error
PurgeTags purges all keys+tags by tag(s)
func (*RedisBackend) Set ¶
func (b *RedisBackend) Set(key string, entry Entry) error
Set a cache key
func (*RedisBackend) Status ¶ added in v0.3.0
func (b *RedisBackend) Status() (bool, string)
Status checks the health of the used redis instance
type RedisBackendConfig ¶
RedisBackendConfig holds the configuration values
type RedisBackendFactory ¶
type RedisBackendFactory struct {
// contains filtered or unexported fields
}
RedisBackendFactory creates fully configured instances of Redis
func (*RedisBackendFactory) Build ¶
func (f *RedisBackendFactory) Build() (Backend, error)
Build a new redis backend
func (*RedisBackendFactory) Inject ¶
func (f *RedisBackendFactory) Inject(logger flamingo.Logger) *RedisBackendFactory
Inject Redis dependencies
func (*RedisBackendFactory) SetConfig ¶
func (f *RedisBackendFactory) SetConfig(config RedisBackendConfig) *RedisBackendFactory
SetConfig for redis
func (*RedisBackendFactory) SetFrontendName ¶
func (f *RedisBackendFactory) SetFrontendName(frontendName string) *RedisBackendFactory
SetFrontendName for redis cache metrics
func (*RedisBackendFactory) SetPool ¶
func (f *RedisBackendFactory) SetPool(pool *redis.Pool) *RedisBackendFactory
SetPool directly - use instead of SetConfig if desired
type TagSupporting ¶
TagSupporting describes a cache backend, responsible for storing, flushing, setting and getting entries
type TwoLevelBackend ¶
type TwoLevelBackend struct {
// contains filtered or unexported fields
}
TwoLevelBackend the cache backend interface with a two level solution
func (*TwoLevelBackend) Flush ¶
func (mb *TwoLevelBackend) Flush() (err error)
Flush the whole cache
func (*TwoLevelBackend) Get ¶
func (mb *TwoLevelBackend) Get(key string) (entry Entry, found bool)
Get entry by key
func (*TwoLevelBackend) Purge ¶
func (mb *TwoLevelBackend) Purge(key string) (err error)
Purge entry by key
func (*TwoLevelBackend) Set ¶
func (mb *TwoLevelBackend) Set(key string, entry Entry) error
Set entry for key
func (*TwoLevelBackend) Status ¶ added in v0.3.0
func (mb *TwoLevelBackend) Status() (bool, string)
Status checks the health of the used backends
type TwoLevelBackendConfig ¶
TwoLevelBackendConfig defines the backends to be used
type TwoLevelBackendFactory ¶
type TwoLevelBackendFactory struct {
// contains filtered or unexported fields
}
TwoLevelBackendFactory creates instances of TwoLevel backends
func (*TwoLevelBackendFactory) Build ¶
func (f *TwoLevelBackendFactory) Build() (Backend, error)
Build the instance
func (*TwoLevelBackendFactory) Inject ¶
func (f *TwoLevelBackendFactory) Inject(logger flamingo.Logger) *TwoLevelBackendFactory
Inject dependencies
func (*TwoLevelBackendFactory) SetConfig ¶
func (f *TwoLevelBackendFactory) SetConfig(config TwoLevelBackendConfig) *TwoLevelBackendFactory
SetConfig for factory