Documentation
¶
Overview ¶
Package inmem is a generated GoMock package.
Index ¶
- Variables
- type Cache
- type Item
- type MockCache
- func (m *MockCache) Begin() error
- func (m *MockCache) Clear()
- func (m *MockCache) Commit() error
- func (m *MockCache) Delete(key string)
- func (m *MockCache) Dump() error
- func (m *MockCache) EXPECT() *MockCacheMockRecorder
- func (m *MockCache) Get(key string) (any, bool)
- func (m *MockCache) Rollback() error
- func (m *MockCache) Set(key string, value any, ttl int64)
- func (m *MockCache) Size() int
- func (m *MockCache) TransactionType() TransactionType
- type MockCacheMockRecorder
- func (mr *MockCacheMockRecorder) Begin() *gomock.Call
- func (mr *MockCacheMockRecorder) Clear() *gomock.Call
- func (mr *MockCacheMockRecorder) Commit() *gomock.Call
- func (mr *MockCacheMockRecorder) Delete(key any) *gomock.Call
- func (mr *MockCacheMockRecorder) Dump() *gomock.Call
- func (mr *MockCacheMockRecorder) Get(key any) *gomock.Call
- func (mr *MockCacheMockRecorder) Rollback() *gomock.Call
- func (mr *MockCacheMockRecorder) Set(key, value, ttl any) *gomock.Call
- func (mr *MockCacheMockRecorder) Size() *gomock.Call
- func (mr *MockCacheMockRecorder) TransactionType() *gomock.Call
- type Options
- type TransactionType
Constants ¶
This section is empty.
Variables ¶
var ( ErrorInTransaction = errors.New("already in transaction") ErrNotInTransaction = errors.New("not in transaction") )
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface {
// Size returns the number of items in the cache.
Size() int
// Get returns a value from the cache given a key.
Get(key string) (any, bool)
// Set sets a key in the cache with a value and a time-to-live (TTL).
Set(key string, value any, ttl int64)
// Delete deletes a key from the cache.
Delete(key string)
// Clear clears all items from the cache.
Clear()
// Dump saves the cache to the configured directory.
Dump() error
// TransactionType returns the type of the transaction.
TransactionType() TransactionType
// Begin starts a transaction.
Begin() error
// Commit commits a transaction.
Commit() error
// Rollback rolls back a transaction.
Rollback() error
}
Cache is the interface that defines the methods for a cache store.
type Item ¶
type Item struct {
// Object is the actual data to be stored in the cache.
Object any
// Expiration is the unix time when the entry will get expired/evicted from the cache.
Expiration int64
}
Item represents a cache item.
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.
func (*MockCache) TransactionType ¶
func (m *MockCache) TransactionType() TransactionType
TransactionType mocks base method.
type MockCacheMockRecorder ¶
type MockCacheMockRecorder struct {
// contains filtered or unexported fields
}
MockCacheMockRecorder is the mock recorder for MockCache.
func (*MockCacheMockRecorder) Begin ¶
func (mr *MockCacheMockRecorder) Begin() *gomock.Call
Begin indicates an expected call of Begin.
func (*MockCacheMockRecorder) Clear ¶
func (mr *MockCacheMockRecorder) Clear() *gomock.Call
Clear indicates an expected call of Clear.
func (*MockCacheMockRecorder) Commit ¶
func (mr *MockCacheMockRecorder) Commit() *gomock.Call
Commit indicates an expected call of Commit.
func (*MockCacheMockRecorder) Delete ¶
func (mr *MockCacheMockRecorder) Delete(key any) *gomock.Call
Delete indicates an expected call of Delete.
func (*MockCacheMockRecorder) Dump ¶
func (mr *MockCacheMockRecorder) Dump() *gomock.Call
Dump indicates an expected call of Dump.
func (*MockCacheMockRecorder) Get ¶
func (mr *MockCacheMockRecorder) Get(key any) *gomock.Call
Get indicates an expected call of Get.
func (*MockCacheMockRecorder) Rollback ¶
func (mr *MockCacheMockRecorder) Rollback() *gomock.Call
Rollback indicates an expected call of Rollback.
func (*MockCacheMockRecorder) Set ¶
func (mr *MockCacheMockRecorder) Set(key, value, ttl any) *gomock.Call
Set indicates an expected call of Set.
func (*MockCacheMockRecorder) Size ¶
func (mr *MockCacheMockRecorder) Size() *gomock.Call
Size indicates an expected call of Size.
func (*MockCacheMockRecorder) TransactionType ¶
func (mr *MockCacheMockRecorder) TransactionType() *gomock.Call
TransactionType indicates an expected call of TransactionType.
type Options ¶
type Options struct {
// Finalizer is the finalizer function that is called when an item is evicted from the cache.
// Note: When in transaction, the finalizer is called after the transaction is committed.
Finalizer func(string, any)
// TransactionType is the type of transaction to be used.
// Options are:
// 1. Optimistic
// 2. Pessimistic
TransactionType TransactionType
// Sync enables the cache to be synchronized with a folder.
// When sharding is enabled, the defined folder will container multiple .gob files (one per peach shard)
Sync bool
// SyncFolderPath is the path to the folder where the cache will be synchronized.
SyncFolderPath string
// SyncInterval is the interval at which the cache will be synchronized.
SyncInterval time.Duration
// Sharding enables the cache to be sharded.
Sharding bool
// ShardCount is the number of shards to be created.
ShardCount uint32
// SupressLog suppresses the logs.
SupressLog bool
// DebugLogs enables the debug logs.
DebugLogs bool
// EvictionPolicy is the eviction policy to be used.
EvictionPolicy eviction.Policy
// MaxSize is the maximum size of the cache, after this size is reached, the cache will start evicting items.
MaxSize int
}
Options represents the options for the cache store initialization.
type TransactionType ¶
type TransactionType string
const ( TransactionTypeAtomic TransactionType = "atomic" TransactionTypeOptimistic TransactionType = "optimistic" )