Documentation ¶
Index ¶
Constants ¶
const ( // CacheDummy configuration key CacheDummy = "dummy" // CacheInMemory configuration key CacheInMemory = "inmemory" )
const (
// CacheRedis configuration key
CacheRedis = "redis"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cache ¶
type Cache interface { Contains(key string) bool Get(key string) interface{} Set(key string, value interface{}) Clear() }
Cache is a simple interface to interact with different cache mechanisms supported on thumbla
type DummyCache ¶
type DummyCache struct { }
DummyCache provider an empty cache implementation that caches nothing!
func NewDummyCache ¶
func NewDummyCache(cfg *config.Config) *DummyCache
NewDummyCache returns a new dummy cache that does nothing
func (*DummyCache) Contains ¶
func (m *DummyCache) Contains(key string) bool
Contains checks if a key exists in the cache
func (*DummyCache) Get ¶
func (m *DummyCache) Get(key string) interface{}
Get returns a cached item, if it exists, otherwise returns nil
func (*DummyCache) Set ¶
func (m *DummyCache) Set(key string, value interface{})
Set saves an item into the cache
type InMemoryCache ¶
InMemoryCache providers a generic in-memory LRU cache
func NewInMemoryCache ¶
func NewInMemoryCache(cfg *config.Config) *InMemoryCache
NewInMemoryCache returns a new instance of the in-memory LRU based cache
func (*InMemoryCache) Contains ¶
func (m *InMemoryCache) Contains(key string) bool
Contains checks if a key exists in the cache
func (*InMemoryCache) Get ¶
func (m *InMemoryCache) Get(key string) interface{}
Get returns a cached item, if it exists, otherwise returns nil
func (*InMemoryCache) Set ¶
func (m *InMemoryCache) Set(key string, value interface{})
Set saves an item into the cache
type RedisCache ¶
type RedisCache struct {
// contains filtered or unexported fields
}
RedisCache provides Redis-backed LRU cache implementation
func NewRedisCache ¶
func NewRedisCache(cfg *config.Config) *RedisCache
NewRedisCache returns a new Redis cache instance
func (*RedisCache) Clear ¶
func (r *RedisCache) Clear()
Clear removes all items from the Redis cache
func (*RedisCache) Contains ¶
func (r *RedisCache) Contains(key string) bool
Contains checks if a key exists in the Redis cache
func (*RedisCache) Get ¶
func (r *RedisCache) Get(key string) interface{}
Get returns a cached item from Redis if it exists
func (*RedisCache) Set ¶
func (r *RedisCache) Set(key string, value interface{})
Set saves an item into Redis cache