Documentation ¶
Index ¶
- Variables
- func AddCacheFlagsToCmd(cmd *cobra.Command, opts ...func(client *redis.Client)) func() (*Cache, error)
- func CollectMetrics(client *redis.Client, registry MetricsRegistry)
- func NewTwoLevelClient(client CacheClient, inMemoryExpiration time.Duration) *twoLevelClient
- type Cache
- func (c *Cache) GetClient() CacheClient
- func (c *Cache) GetItem(key string, item interface{}) error
- func (c *Cache) NotifyUpdated(key string) error
- func (c *Cache) OnUpdated(ctx context.Context, key string, callback func() error) error
- func (c *Cache) SetClient(client CacheClient)
- func (c *Cache) SetItem(key string, item interface{}, expiration time.Duration, delete bool) error
- type CacheClient
- type InMemoryCache
- func (i *InMemoryCache) Delete(key string) error
- func (i *InMemoryCache) Flush()
- func (i *InMemoryCache) Get(key string, obj interface{}) error
- func (i *InMemoryCache) HasSame(key string, obj interface{}) (bool, error)
- func (i *InMemoryCache) Items(createNewObject func() interface{}) (map[string]interface{}, error)
- func (i *InMemoryCache) NotifyUpdated(key string) error
- func (i *InMemoryCache) OnUpdated(ctx context.Context, key string, callback func() error) error
- func (i *InMemoryCache) Set(item *Item) error
- type Item
- type MetricsRegistry
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrCacheMiss = errors.New("cache: key is missing")
Functions ¶
func AddCacheFlagsToCmd ¶ added in v0.12.0
func AddCacheFlagsToCmd(cmd *cobra.Command, opts ...func(client *redis.Client)) func() (*Cache, error)
AddCacheFlagsToCmd adds flags which control caching to the specified command
func CollectMetrics ¶ added in v1.5.5
func CollectMetrics(client *redis.Client, registry MetricsRegistry)
CollectMetrics add transport wrapper that pushes metrics into the specified metrics registry
func NewTwoLevelClient ¶ added in v1.8.5
func NewTwoLevelClient(client CacheClient, inMemoryExpiration time.Duration) *twoLevelClient
NewTwoLevelClient creates cache client that proxies requests to given external cache and tries to minimize number of requests to external client by storing cache entries in local in-memory cache.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache provides strongly types methods to store and retrieve values from shared cache
func NewCache ¶ added in v0.12.0
func NewCache(client CacheClient) *Cache
func (*Cache) GetClient ¶ added in v1.8.5
func (c *Cache) GetClient() CacheClient
func (*Cache) NotifyUpdated ¶ added in v1.7.3
func (*Cache) SetClient ¶ added in v1.8.5
func (c *Cache) SetClient(client CacheClient)
type CacheClient ¶ added in v0.12.0
type CacheClient interface { Set(item *Item) error Get(key string, obj interface{}) error Delete(key string) error OnUpdated(ctx context.Context, key string, callback func() error) error NotifyUpdated(key string) error }
func NewRedisCache ¶
func NewRedisCache(client *redis.Client, expiration time.Duration) CacheClient
type InMemoryCache ¶ added in v0.9.0
type InMemoryCache struct {
// contains filtered or unexported fields
}
func NewInMemoryCache ¶
func NewInMemoryCache(expiration time.Duration) *InMemoryCache
func (*InMemoryCache) Delete ¶ added in v0.11.0
func (i *InMemoryCache) Delete(key string) error
func (*InMemoryCache) Flush ¶ added in v0.9.0
func (i *InMemoryCache) Flush()
func (*InMemoryCache) Get ¶ added in v0.9.0
func (i *InMemoryCache) Get(key string, obj interface{}) error
func (*InMemoryCache) HasSame ¶ added in v1.8.5
func (i *InMemoryCache) HasSame(key string, obj interface{}) (bool, error)
HasSame returns true if key with the same value already present in cache
func (*InMemoryCache) Items ¶ added in v1.8.0
func (i *InMemoryCache) Items(createNewObject func() interface{}) (map[string]interface{}, error)
Items return a list of items in the cache; requires passing a constructor function so that the items can be decoded from gob format.
func (*InMemoryCache) NotifyUpdated ¶ added in v1.7.3
func (i *InMemoryCache) NotifyUpdated(key string) error
func (*InMemoryCache) Set ¶ added in v0.9.0
func (i *InMemoryCache) Set(item *Item) error
type MetricsRegistry ¶ added in v1.5.5
Click to show internal directories.
Click to hide internal directories.