Documentation
¶
Overview ¶
Package cache contains different byte-cache implementations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Cacher ¶
type Cacher interface {
// TTL returns current cache values time-to-live.
TTL() time.Duration
// Get value associated with the key from the storage.
Get(key string) (found bool, data []byte, ttl time.Duration, err error)
// Put value into the storage.
Put(key string, data []byte) error
// Delete value from the storage with passed key.
Delete(key string) (bool, error)
}
Cacher is a byte-based cache with TTL.
type InMemoryCache ¶
type InMemoryCache struct {
// contains filtered or unexported fields
}
InMemoryCache is an inmemory cache (with TTL) implementation.
func NewInMemoryCache ¶
func NewInMemoryCache(ttl time.Duration, ci time.Duration) *InMemoryCache
NewInMemoryCache creates inmemory storage with TTL.
func (*InMemoryCache) Close ¶
func (c *InMemoryCache) Close() error
Close current in memory storage with data invalidation.
func (*InMemoryCache) Delete ¶
func (c *InMemoryCache) Delete(key string) (bool, error)
Delete value from the storage with passed key.
func (*InMemoryCache) Put ¶
func (c *InMemoryCache) Put(key string, data []byte) error
Put value into the storage.
func (*InMemoryCache) TTL ¶
func (c *InMemoryCache) TTL() time.Duration
TTL returns current cache values time-to-live.
type RedisCache ¶
type RedisCache struct {
// contains filtered or unexported fields
}
RedisCache is a redis cache implementation.
func NewRedisCache ¶
func NewRedisCache(ctx context.Context, client *redis.Client, ttl time.Duration) *RedisCache
NewRedisCache creates new redis cache instance.
func (*RedisCache) Delete ¶
func (c *RedisCache) Delete(key string) (bool, error)
Delete value from the storage with passed key.
func (*RedisCache) Put ¶
func (c *RedisCache) Put(key string, data []byte) error
Put value into the storage.
func (*RedisCache) TTL ¶
func (c *RedisCache) TTL() time.Duration
TTL returns current cache values time-to-live.
Click to show internal directories.
Click to hide internal directories.