Documentation ¶
Index ¶
- type BehaviorOption
- type CCache
- func (c *CCache) Delete(key string) bool
- func (c *CCache) Get(key string) interface{}
- func (c *CCache) GetInt(key string) int
- func (c *CCache) GetInt64(key string) int64
- func (c *CCache) GetString(key string) string
- func (c *CCache) IsEnabled() bool
- func (c *CCache) Set(key string, val interface{})
- func (c *CCache) SetInt(key string, val int)
- func (c *CCache) SetInt64(key string, val int64)
- func (c *CCache) SetString(key string, val string)
- type CInterface
- type Manager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BehaviorOption ¶ added in v1.2.18
type BehaviorOption int
const ( // StrictExpiry sets the behavior so that an expired item will never be returned by the cache. // // The default behavior is that items are returned until they have been purged from the cache by an // synchronous reaper // NOTE: see issue https://github.com/hyperledger/firefly-common/issues/85 on operation of the async reaper. StrictExpiry BehaviorOption = iota // TTLFromInitialAdd sets the behavior so that the time-to-live for a cache entry is set when // it is added, and not extended when the item is accessed. // This is useful if you have code that wants to rely on a cache-miss as a way to force regular // synchronization of cached data with a remote source of truth // // The default behavior is that the TTL is extended each time a cache entry is accessed. // This is useful if you're managing the cache such that the data inside it is always valid, // and want to keep the most frequently accessed data in the cache indefinitely. TTLFromInitialAdd )
type CInterface ¶
type CInterface interface { IsEnabled() bool Delete(key string) bool Get(key string) interface{} Set(key string, val interface{}) GetString(key string) string SetString(key string, val string) GetInt(key string) int SetInt(key string, val int) GetInt64(key string) int64 SetInt64(key string, val int64) }
CInterface contains functions a cache instance need to provide
func NewUmanagedCache ¶
should only be used for testing purpose
type Manager ¶
type Manager interface { // Get a cache by name, if a cache already exists with the same name, it will be returned as is without checking maxSize, ttl and enabled matches GetCache(ctx context.Context, namespace, name string, maxSize int64, ttl time.Duration, enabled bool, behaviorOptions ...BehaviorOption) (CInterface, error) ListCacheNames(namespace string) []string ResetCaches(namespace string) IsEnabled() bool }
Manager contains functions to manage cache instances. It provides functions for creating new cache instances and list all of the names of existing cache instances Each cache instance has unique name and its own cache size and TTL configuration.
Click to show internal directories.
Click to hide internal directories.