Documentation ¶
Overview ¶
Package cache is a generated GoMock package.
Package cache provides the implementation of eviction policy based Cache this package can be extended to implement caches based on other eviction policies
cache in this package take locks while operating, and are therefore thread-safe for consumers
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterCache ¶
func RegisterCache(policy EvictionPolicy, cache Composer)
RegisterCache registers various implementation of Cache interface based on eviction policy
Types ¶
type Cache ¶
type Cache interface { // Put inserts the provided key/value pair into the gocache, // making it available for future get() calls Put(key, value string) // Get returns a value previously provided via Put(). An empty Option // may be returned if the requested data was never inserted or is // no longer available. Get(key string) (string, error) }
Cache interface is implemented by all caches
type Composer ¶
type Composer interface { Cache Initializer }
type Config ¶
type Config struct { Policy EvictionPolicy `json:"evictionPolicy"` Size int `json:"capacity"` }
Config is cache configuration
type EvictionPolicy ¶
type EvictionPolicy string
EvictionPolicy defines gocache type (LRU, LFU etc)
const (
LRU EvictionPolicy = "LRU"
)
func (EvictionPolicy) String ¶
func (e EvictionPolicy) String() string
type Initializer ¶
type Initializer interface { // Initialize instantiates a particular type of gocache based on eviction policy Initialize(size int) }
type MockCache ¶
type MockCache struct {
// contains filtered or unexported fields
}
MockCache is a mock of Cache interface.
func NewMockCache ¶
func NewMockCache(ctrl *gomock.Controller) *MockCache
NewMockCache creates a new mock instance.
func (*MockCache) EXPECT ¶
func (m *MockCache) EXPECT() *MockCacheMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockCacheMockRecorder ¶
type MockCacheMockRecorder struct {
// contains filtered or unexported fields
}
MockCacheMockRecorder is the mock recorder for MockCache.
func (*MockCacheMockRecorder) Get ¶
func (mr *MockCacheMockRecorder) Get(key interface{}) *gomock.Call
Get indicates an expected call of Get.
func (*MockCacheMockRecorder) Put ¶
func (mr *MockCacheMockRecorder) Put(key, value interface{}) *gomock.Call
Put indicates an expected call of Put.
type MockComposer ¶
type MockComposer struct {
// contains filtered or unexported fields
}
MockComposer is a mock of Composer interface.
func NewMockComposer ¶
func NewMockComposer(ctrl *gomock.Controller) *MockComposer
NewMockComposer creates a new mock instance.
func (*MockComposer) EXPECT ¶
func (m *MockComposer) EXPECT() *MockComposerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockComposer) Get ¶
func (m *MockComposer) Get(key string) (string, error)
Get mocks base method.
func (*MockComposer) Initialize ¶
func (m *MockComposer) Initialize(size int)
Initialize mocks base method.
type MockComposerMockRecorder ¶
type MockComposerMockRecorder struct {
// contains filtered or unexported fields
}
MockComposerMockRecorder is the mock recorder for MockComposer.
func (*MockComposerMockRecorder) Get ¶
func (mr *MockComposerMockRecorder) Get(key interface{}) *gomock.Call
Get indicates an expected call of Get.
func (*MockComposerMockRecorder) Initialize ¶
func (mr *MockComposerMockRecorder) Initialize(size interface{}) *gomock.Call
Initialize indicates an expected call of Initialize.
func (*MockComposerMockRecorder) Put ¶
func (mr *MockComposerMockRecorder) Put(key, value interface{}) *gomock.Call
Put indicates an expected call of Put.
type MockInitializer ¶
type MockInitializer struct {
// contains filtered or unexported fields
}
MockInitializer is a mock of Initializer interface.
func NewMockInitializer ¶
func NewMockInitializer(ctrl *gomock.Controller) *MockInitializer
NewMockInitializer creates a new mock instance.
func (*MockInitializer) EXPECT ¶
func (m *MockInitializer) EXPECT() *MockInitializerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockInitializer) Initialize ¶
func (m *MockInitializer) Initialize(size int)
Initialize mocks base method.
type MockInitializerMockRecorder ¶
type MockInitializerMockRecorder struct {
// contains filtered or unexported fields
}
MockInitializerMockRecorder is the mock recorder for MockInitializer.
func (*MockInitializerMockRecorder) Initialize ¶
func (mr *MockInitializerMockRecorder) Initialize(size interface{}) *gomock.Call
Initialize indicates an expected call of Initialize.