Documentation ¶
Index ¶
- func MakeKey(keys ...string) string
- func NewFastMemoryCache(opts *CacheOpts) *fastMemoryCache
- func NewInMemoryCache(opts *CacheOpts) *inMemoryCache
- func NewShardedClusterRedisCache(opts *CacheOpts, watcher ITimer) *redisCache
- func NewTinyCache(opts *CacheOpts) *tinyCache
- type CacheOpts
- type DummyCounter
- type DummyTimer
- type ErrCacheMiss
- type ICache
- type ICounter
- type ITimer
- type MemoryOpts
- type Mnemosyne
- type MnemosyneInstance
- func (mn *MnemosyneInstance) Delete(ctx context.Context, key string) error
- func (mn *MnemosyneInstance) Flush(targetLayerName string) error
- func (mn *MnemosyneInstance) Get(ctx context.Context, key string, refrence interface{}) (interface{}, error)
- func (mn *MnemosyneInstance) GetAndShouldUpdate(ctx context.Context, key string, refrence interface{}) (interface{}, bool, error)
- func (mn *MnemosyneInstance) Set(ctx context.Context, key string, value interface{}) error
- func (mn *MnemosyneInstance) ShouldUpdate(ctx context.Context, key string) (bool, error)
- func (mn *MnemosyneInstance) ShouldUpdateDeep(ctx context.Context, key string, refrence interface{}) (bool, error)
- func (mn *MnemosyneInstance) TTL(ctx context.Context, key string) (int, time.Duration)
- type RedisClusterAddress
- type RedisOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewFastMemoryCache ¶
func NewFastMemoryCache(opts *CacheOpts) *fastMemoryCache
func NewInMemoryCache ¶
func NewInMemoryCache(opts *CacheOpts) *inMemoryCache
func NewTinyCache ¶
func NewTinyCache(opts *CacheOpts) *tinyCache
Types ¶
type DummyCounter ¶
type DummyCounter struct { }
func NewDummyCounter ¶
func NewDummyCounter() *DummyCounter
func (*DummyCounter) Inc ¶
func (*DummyCounter) Inc(...string)
type DummyTimer ¶
type DummyTimer struct { }
func NewDummyTimer ¶
func NewDummyTimer() *DummyTimer
func (*DummyTimer) Start ¶
func (*DummyTimer) Start() time.Time
type ErrCacheMiss ¶
type ErrCacheMiss struct {
// contains filtered or unexported fields
}
ErrCacheMiss is the Error returned when a cache miss happens
func (*ErrCacheMiss) Error ¶
func (e *ErrCacheMiss) Error() string
type ICache ¶
type ICache interface { Get(context.Context, string, interface{}) (*cachable, error) Set(context.Context, string, *cachable) error Delete(context.Context, string) error Clear() error TTL(context.Context, string) time.Duration Name() string }
func NewCacheLayer ¶
type MemoryOpts ¶
type MemoryOpts struct {
// contains filtered or unexported fields
}
type Mnemosyne ¶
type Mnemosyne struct {
// contains filtered or unexported fields
}
Mnemosyne is the parent object which holds all cache instances
func NewMnemosyne ¶
NewMnemosyne initializes the Mnemosyne object which holds all the cache instances
func (*Mnemosyne) Select ¶
func (m *Mnemosyne) Select(cacheName string) *MnemosyneInstance
Select returns a cache instance selected by name
type MnemosyneInstance ¶
type MnemosyneInstance struct {
// contains filtered or unexported fields
}
MnemosyneInstance is an instance of a multi-layer cache
func (*MnemosyneInstance) Delete ¶
func (mn *MnemosyneInstance) Delete(ctx context.Context, key string) error
Delete removes a key from all the layers (if exists)
func (*MnemosyneInstance) Flush ¶
func (mn *MnemosyneInstance) Flush(targetLayerName string) error
Flush completly clears a single layer of the cache
func (*MnemosyneInstance) Get ¶
func (mn *MnemosyneInstance) Get(ctx context.Context, key string, refrence interface{}) (interface{}, error)
Get retrieves the value for key
func (*MnemosyneInstance) GetAndShouldUpdate ¶
func (mn *MnemosyneInstance) GetAndShouldUpdate(ctx context.Context, key string, refrence interface{}) (interface{}, bool, error)
GetAndShouldUpdate retrieves the value for key and also shows whether the soft-TTL of that key has passed or not
func (*MnemosyneInstance) Set ¶
func (mn *MnemosyneInstance) Set(ctx context.Context, key string, value interface{}) error
Set sets the value for a key in all layers of the cache instance
func (*MnemosyneInstance) ShouldUpdate ¶
ShouldUpdate shows whether the soft-TTL of a key has passed or not
func (*MnemosyneInstance) ShouldUpdateDeep ¶
func (mn *MnemosyneInstance) ShouldUpdateDeep(ctx context.Context, key string, refrence interface{}) (bool, error)
ShouldUpdateDeep checks all layers for newer result and will sync older cache layers