Documentation ¶
Overview ¶
Package cache is a generated GoMock package.
Index ¶
- Constants
- type Cache
- func (c *Cache[T]) Clear(ctx context.Context) error
- func (c *Cache[T]) Delete(ctx context.Context, key any) error
- func (c *Cache[T]) Get(ctx context.Context, key any) (T, error)
- func (c *Cache[T]) GetCodec() codec.CodecInterface
- func (c *Cache[T]) GetType() string
- func (c *Cache[T]) GetWithTTL(ctx context.Context, key any) (T, time.Duration, error)
- func (c *Cache[T]) Invalidate(ctx context.Context, options ...store.InvalidateOption) error
- func (c *Cache[T]) Set(ctx context.Context, key any, object T, options ...store.Option) error
- type CacheInterface
- type CacheKeyGenerator
- type ChainCache
- func (c *ChainCache[T]) Clear(ctx context.Context) error
- func (c *ChainCache[T]) Delete(ctx context.Context, key any) error
- func (c *ChainCache[T]) Get(ctx context.Context, key any) (T, error)
- func (c *ChainCache[T]) GetCaches() []SetterCacheInterface[T]
- func (c *ChainCache[T]) GetType() string
- func (c *ChainCache[T]) Invalidate(ctx context.Context, options ...store.InvalidateOption) error
- func (c *ChainCache[T]) Set(ctx context.Context, key any, object T, options ...store.Option) error
- type LoadFunction
- type LoadableCache
- func (c *LoadableCache[T]) Clear(ctx context.Context) error
- func (c *LoadableCache[T]) Close() error
- func (c *LoadableCache[T]) Delete(ctx context.Context, key any) error
- func (c *LoadableCache[T]) Get(ctx context.Context, key any) (T, error)
- func (c *LoadableCache[T]) GetType() string
- func (c *LoadableCache[T]) Invalidate(ctx context.Context, options ...store.InvalidateOption) error
- func (c *LoadableCache[T]) Set(ctx context.Context, key any, object T, options ...store.Option) error
- type MetricCache
- func (c *MetricCache[T]) Clear(ctx context.Context) error
- func (c *MetricCache[T]) Delete(ctx context.Context, key any) error
- func (c *MetricCache[T]) Get(ctx context.Context, key any) (T, error)
- func (c *MetricCache[T]) GetType() string
- func (c *MetricCache[T]) Invalidate(ctx context.Context, options ...store.InvalidateOption) error
- func (c *MetricCache[T]) Set(ctx context.Context, key any, object T, options ...store.Option) error
- type MockCacheInterface
- func (m *MockCacheInterface[T]) Clear(ctx context.Context) error
- func (m *MockCacheInterface[T]) Delete(ctx context.Context, key any) error
- func (m *MockCacheInterface[T]) EXPECT() *MockCacheInterfaceMockRecorder[T]
- func (m *MockCacheInterface[T]) Get(ctx context.Context, key any) (T, error)
- func (m *MockCacheInterface[T]) GetType() string
- func (m *MockCacheInterface[T]) Invalidate(ctx context.Context, options ...store.InvalidateOption) error
- func (m *MockCacheInterface[T]) Set(ctx context.Context, key any, object T, options ...store.Option) error
- type MockCacheInterfaceMockRecorder
- func (mr *MockCacheInterfaceMockRecorder[T]) Clear(ctx interface{}) *gomock.Call
- func (mr *MockCacheInterfaceMockRecorder[T]) Delete(ctx, key interface{}) *gomock.Call
- func (mr *MockCacheInterfaceMockRecorder[T]) Get(ctx, key interface{}) *gomock.Call
- func (mr *MockCacheInterfaceMockRecorder[T]) GetType() *gomock.Call
- func (mr *MockCacheInterfaceMockRecorder[T]) Invalidate(ctx interface{}, options ...interface{}) *gomock.Call
- func (mr *MockCacheInterfaceMockRecorder[T]) Set(ctx, key, object interface{}, options ...interface{}) *gomock.Call
- type MockCacheKeyGenerator
- type MockCacheKeyGeneratorMockRecorder
- type MockSetterCacheInterface
- func (m *MockSetterCacheInterface[T]) Clear(ctx context.Context) error
- func (m *MockSetterCacheInterface[T]) Delete(ctx context.Context, key any) error
- func (m *MockSetterCacheInterface[T]) EXPECT() *MockSetterCacheInterfaceMockRecorder[T]
- func (m *MockSetterCacheInterface[T]) Get(ctx context.Context, key any) (T, error)
- func (m *MockSetterCacheInterface[T]) GetCodec() codec.CodecInterface
- func (m *MockSetterCacheInterface[T]) GetType() string
- func (m *MockSetterCacheInterface[T]) GetWithTTL(ctx context.Context, key any) (T, time.Duration, error)
- func (m *MockSetterCacheInterface[T]) Invalidate(ctx context.Context, options ...store.InvalidateOption) error
- func (m *MockSetterCacheInterface[T]) Set(ctx context.Context, key any, object T, options ...store.Option) error
- type MockSetterCacheInterfaceMockRecorder
- func (mr *MockSetterCacheInterfaceMockRecorder[T]) Clear(ctx interface{}) *gomock.Call
- func (mr *MockSetterCacheInterfaceMockRecorder[T]) Delete(ctx, key interface{}) *gomock.Call
- func (mr *MockSetterCacheInterfaceMockRecorder[T]) Get(ctx, key interface{}) *gomock.Call
- func (mr *MockSetterCacheInterfaceMockRecorder[T]) GetCodec() *gomock.Call
- func (mr *MockSetterCacheInterfaceMockRecorder[T]) GetType() *gomock.Call
- func (mr *MockSetterCacheInterfaceMockRecorder[T]) GetWithTTL(ctx, key interface{}) *gomock.Call
- func (mr *MockSetterCacheInterfaceMockRecorder[T]) Invalidate(ctx interface{}, options ...interface{}) *gomock.Call
- func (mr *MockSetterCacheInterfaceMockRecorder[T]) Set(ctx, key, object interface{}, options ...interface{}) *gomock.Call
- type SetterCacheInterface
Constants ¶
const (
// CacheType represents the cache type as a string value
CacheType = "cache"
)
const (
// ChainType represents the chain cache type as a string value
ChainType = "chain"
)
const (
// LoadableType represents the loadable cache type as a string value
LoadableType = "loadable"
)
const (
// MetricType represents the metric cache type as a string value
MetricType = "metric"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache[T any] struct { // contains filtered or unexported fields }
Cache represents the configuration needed by a cache
func (*Cache[T]) GetCodec ¶
func (c *Cache[T]) GetCodec() codec.CodecInterface
GetCodec returns the current codec
func (*Cache[T]) GetWithTTL ¶
GetWithTTL returns the object stored in cache and its corresponding TTL
func (*Cache[T]) Invalidate ¶
Invalidate invalidates cache item from given options
type CacheInterface ¶
type CacheInterface[T any] interface { Get(ctx context.Context, key any) (T, error) Set(ctx context.Context, key any, object T, options ...store.Option) error Delete(ctx context.Context, key any) error Invalidate(ctx context.Context, options ...store.InvalidateOption) error Clear(ctx context.Context) error GetType() string }
CacheInterface represents the interface for all caches (aggregates, metric, memory, redis, ...)
type CacheKeyGenerator ¶
type CacheKeyGenerator interface {
GetCacheKey() string
}
type ChainCache ¶
type ChainCache[T any] struct { // contains filtered or unexported fields }
ChainCache represents the configuration needed by a cache aggregator
func NewChain ¶
func NewChain[T any](caches ...SetterCacheInterface[T]) *ChainCache[T]
NewChain instantiates a new cache aggregator
func (*ChainCache[T]) Clear ¶
func (c *ChainCache[T]) Clear(ctx context.Context) error
Clear resets all cache data
func (*ChainCache[T]) Delete ¶
func (c *ChainCache[T]) Delete(ctx context.Context, key any) error
Delete removes a value from all available caches
func (*ChainCache[T]) Get ¶
func (c *ChainCache[T]) Get(ctx context.Context, key any) (T, error)
Get returns the object stored in cache if it exists
func (*ChainCache[T]) GetCaches ¶
func (c *ChainCache[T]) GetCaches() []SetterCacheInterface[T]
GetCaches returns all Chained caches
func (*ChainCache[T]) GetType ¶
func (c *ChainCache[T]) GetType() string
GetType returns the cache type
func (*ChainCache[T]) Invalidate ¶
func (c *ChainCache[T]) Invalidate(ctx context.Context, options ...store.InvalidateOption) error
Invalidate invalidates cache item from given options
type LoadableCache ¶
type LoadableCache[T any] struct { // contains filtered or unexported fields }
LoadableCache represents a cache that uses a function to load data
func NewLoadable ¶
func NewLoadable[T any](loadFunc LoadFunction[T], cache CacheInterface[T]) *LoadableCache[T]
NewLoadable instantiates a new cache that uses a function to load data
func (*LoadableCache[T]) Clear ¶
func (c *LoadableCache[T]) Clear(ctx context.Context) error
Clear resets all cache data
func (*LoadableCache[T]) Close ¶
func (c *LoadableCache[T]) Close() error
func (*LoadableCache[T]) Delete ¶
func (c *LoadableCache[T]) Delete(ctx context.Context, key any) error
Delete removes a value from cache
func (*LoadableCache[T]) Get ¶
func (c *LoadableCache[T]) Get(ctx context.Context, key any) (T, error)
Get returns the object stored in cache if it exists
func (*LoadableCache[T]) GetType ¶
func (c *LoadableCache[T]) GetType() string
GetType returns the cache type
func (*LoadableCache[T]) Invalidate ¶
func (c *LoadableCache[T]) Invalidate(ctx context.Context, options ...store.InvalidateOption) error
Invalidate invalidates cache item from given options
type MetricCache ¶
type MetricCache[T any] struct { // contains filtered or unexported fields }
MetricCache is the struct that specifies metrics available for different caches
func NewMetric ¶
func NewMetric[T any](metrics metrics.MetricsInterface, cache CacheInterface[T]) *MetricCache[T]
NewMetric creates a new cache with metrics and a given cache storage
func (*MetricCache[T]) Clear ¶
func (c *MetricCache[T]) Clear(ctx context.Context) error
Clear resets all cache data
func (*MetricCache[T]) Delete ¶
func (c *MetricCache[T]) Delete(ctx context.Context, key any) error
Delete removes a value from the cache
func (*MetricCache[T]) Get ¶
func (c *MetricCache[T]) Get(ctx context.Context, key any) (T, error)
Get obtains a value from cache and also records metrics
func (*MetricCache[T]) GetType ¶
func (c *MetricCache[T]) GetType() string
GetType returns the cache type
func (*MetricCache[T]) Invalidate ¶
func (c *MetricCache[T]) Invalidate(ctx context.Context, options ...store.InvalidateOption) error
Invalidate invalidates cache item from given options
type MockCacheInterface ¶
type MockCacheInterface[T any] struct { // contains filtered or unexported fields }
MockCacheInterface is a mock of CacheInterface interface.
func NewMockCacheInterface ¶
func NewMockCacheInterface[T any](ctrl *gomock.Controller) *MockCacheInterface[T]
NewMockCacheInterface creates a new mock instance.
func (*MockCacheInterface[T]) Clear ¶
func (m *MockCacheInterface[T]) Clear(ctx context.Context) error
Clear mocks base method.
func (*MockCacheInterface[T]) Delete ¶
func (m *MockCacheInterface[T]) Delete(ctx context.Context, key any) error
Delete mocks base method.
func (*MockCacheInterface[T]) EXPECT ¶
func (m *MockCacheInterface[T]) EXPECT() *MockCacheInterfaceMockRecorder[T]
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockCacheInterface[T]) Get ¶
func (m *MockCacheInterface[T]) Get(ctx context.Context, key any) (T, error)
Get mocks base method.
func (*MockCacheInterface[T]) GetType ¶
func (m *MockCacheInterface[T]) GetType() string
GetType mocks base method.
func (*MockCacheInterface[T]) Invalidate ¶
func (m *MockCacheInterface[T]) Invalidate(ctx context.Context, options ...store.InvalidateOption) error
Invalidate mocks base method.
type MockCacheInterfaceMockRecorder ¶
type MockCacheInterfaceMockRecorder[T any] struct { // contains filtered or unexported fields }
MockCacheInterfaceMockRecorder is the mock recorder for MockCacheInterface.
func (*MockCacheInterfaceMockRecorder[T]) Clear ¶
func (mr *MockCacheInterfaceMockRecorder[T]) Clear(ctx interface{}) *gomock.Call
Clear indicates an expected call of Clear.
func (*MockCacheInterfaceMockRecorder[T]) Delete ¶
func (mr *MockCacheInterfaceMockRecorder[T]) Delete(ctx, key interface{}) *gomock.Call
Delete indicates an expected call of Delete.
func (*MockCacheInterfaceMockRecorder[T]) Get ¶
func (mr *MockCacheInterfaceMockRecorder[T]) Get(ctx, key interface{}) *gomock.Call
Get indicates an expected call of Get.
func (*MockCacheInterfaceMockRecorder[T]) GetType ¶
func (mr *MockCacheInterfaceMockRecorder[T]) GetType() *gomock.Call
GetType indicates an expected call of GetType.
func (*MockCacheInterfaceMockRecorder[T]) Invalidate ¶
func (mr *MockCacheInterfaceMockRecorder[T]) Invalidate(ctx interface{}, options ...interface{}) *gomock.Call
Invalidate indicates an expected call of Invalidate.
func (*MockCacheInterfaceMockRecorder[T]) Set ¶
func (mr *MockCacheInterfaceMockRecorder[T]) Set(ctx, key, object interface{}, options ...interface{}) *gomock.Call
Set indicates an expected call of Set.
type MockCacheKeyGenerator ¶
type MockCacheKeyGenerator struct {
// contains filtered or unexported fields
}
MockCacheKeyGenerator is a mock of CacheKeyGenerator interface.
func NewMockCacheKeyGenerator ¶
func NewMockCacheKeyGenerator(ctrl *gomock.Controller) *MockCacheKeyGenerator
NewMockCacheKeyGenerator creates a new mock instance.
func (*MockCacheKeyGenerator) EXPECT ¶
func (m *MockCacheKeyGenerator) EXPECT() *MockCacheKeyGeneratorMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockCacheKeyGenerator) GetCacheKey ¶
func (m *MockCacheKeyGenerator) GetCacheKey() string
GetCacheKey mocks base method.
type MockCacheKeyGeneratorMockRecorder ¶
type MockCacheKeyGeneratorMockRecorder struct {
// contains filtered or unexported fields
}
MockCacheKeyGeneratorMockRecorder is the mock recorder for MockCacheKeyGenerator.
func (*MockCacheKeyGeneratorMockRecorder) GetCacheKey ¶
func (mr *MockCacheKeyGeneratorMockRecorder) GetCacheKey() *gomock.Call
GetCacheKey indicates an expected call of GetCacheKey.
type MockSetterCacheInterface ¶
type MockSetterCacheInterface[T any] struct { // contains filtered or unexported fields }
MockSetterCacheInterface is a mock of SetterCacheInterface interface.
func NewMockSetterCacheInterface ¶
func NewMockSetterCacheInterface[T any](ctrl *gomock.Controller) *MockSetterCacheInterface[T]
NewMockSetterCacheInterface creates a new mock instance.
func (*MockSetterCacheInterface[T]) Clear ¶
func (m *MockSetterCacheInterface[T]) Clear(ctx context.Context) error
Clear mocks base method.
func (*MockSetterCacheInterface[T]) Delete ¶
func (m *MockSetterCacheInterface[T]) Delete(ctx context.Context, key any) error
Delete mocks base method.
func (*MockSetterCacheInterface[T]) EXPECT ¶
func (m *MockSetterCacheInterface[T]) EXPECT() *MockSetterCacheInterfaceMockRecorder[T]
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockSetterCacheInterface[T]) Get ¶
func (m *MockSetterCacheInterface[T]) Get(ctx context.Context, key any) (T, error)
Get mocks base method.
func (*MockSetterCacheInterface[T]) GetCodec ¶
func (m *MockSetterCacheInterface[T]) GetCodec() codec.CodecInterface
GetCodec mocks base method.
func (*MockSetterCacheInterface[T]) GetType ¶
func (m *MockSetterCacheInterface[T]) GetType() string
GetType mocks base method.
func (*MockSetterCacheInterface[T]) GetWithTTL ¶
func (m *MockSetterCacheInterface[T]) GetWithTTL(ctx context.Context, key any) (T, time.Duration, error)
GetWithTTL mocks base method.
func (*MockSetterCacheInterface[T]) Invalidate ¶
func (m *MockSetterCacheInterface[T]) Invalidate(ctx context.Context, options ...store.InvalidateOption) error
Invalidate mocks base method.
type MockSetterCacheInterfaceMockRecorder ¶
type MockSetterCacheInterfaceMockRecorder[T any] struct { // contains filtered or unexported fields }
MockSetterCacheInterfaceMockRecorder is the mock recorder for MockSetterCacheInterface.
func (*MockSetterCacheInterfaceMockRecorder[T]) Clear ¶
func (mr *MockSetterCacheInterfaceMockRecorder[T]) Clear(ctx interface{}) *gomock.Call
Clear indicates an expected call of Clear.
func (*MockSetterCacheInterfaceMockRecorder[T]) Delete ¶
func (mr *MockSetterCacheInterfaceMockRecorder[T]) Delete(ctx, key interface{}) *gomock.Call
Delete indicates an expected call of Delete.
func (*MockSetterCacheInterfaceMockRecorder[T]) Get ¶
func (mr *MockSetterCacheInterfaceMockRecorder[T]) Get(ctx, key interface{}) *gomock.Call
Get indicates an expected call of Get.
func (*MockSetterCacheInterfaceMockRecorder[T]) GetCodec ¶
func (mr *MockSetterCacheInterfaceMockRecorder[T]) GetCodec() *gomock.Call
GetCodec indicates an expected call of GetCodec.
func (*MockSetterCacheInterfaceMockRecorder[T]) GetType ¶
func (mr *MockSetterCacheInterfaceMockRecorder[T]) GetType() *gomock.Call
GetType indicates an expected call of GetType.
func (*MockSetterCacheInterfaceMockRecorder[T]) GetWithTTL ¶
func (mr *MockSetterCacheInterfaceMockRecorder[T]) GetWithTTL(ctx, key interface{}) *gomock.Call
GetWithTTL indicates an expected call of GetWithTTL.
func (*MockSetterCacheInterfaceMockRecorder[T]) Invalidate ¶
func (mr *MockSetterCacheInterfaceMockRecorder[T]) Invalidate(ctx interface{}, options ...interface{}) *gomock.Call
Invalidate indicates an expected call of Invalidate.
func (*MockSetterCacheInterfaceMockRecorder[T]) Set ¶
func (mr *MockSetterCacheInterfaceMockRecorder[T]) Set(ctx, key, object interface{}, options ...interface{}) *gomock.Call
Set indicates an expected call of Set.
type SetterCacheInterface ¶
type SetterCacheInterface[T any] interface { // CacheInterface[T] TODO: Waiting for gomock to support nested interfaces with generics. Get(ctx context.Context, key any) (T, error) Set(ctx context.Context, key any, object T, options ...store.Option) error Delete(ctx context.Context, key any) error Invalidate(ctx context.Context, options ...store.InvalidateOption) error Clear(ctx context.Context) error GetType() string GetWithTTL(ctx context.Context, key any) (T, time.Duration, error) GetCodec() codec.CodecInterface }
SetterCacheInterface represents the interface for caches that allows storage (for instance: memory, redis, ...)