Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrCacheItemNotFound is returned if cache does not exist ErrCacheItemNotFound = errors.New("cache item not found") // ErrInvalidCacheType is returned if the type is invalid ErrInvalidCacheType = errors.New("invalid remote cache name") )
Functions ¶
func Register ¶
func Register(value interface{})
Register records a type, identified by a value for that type, under its internal type name. That name will identify the concrete type of a value sent or received as an interface variable. Only types that will be transferred as implementations of interface values need to be registered. Expecting to be used only during initialization, it panics if the mapping between types and names is not a bijection.
Types ¶
type CacheStorage ¶
type CacheStorage interface { // Get reads object from Cache Get(key string) (interface{}, error) // Set sets an object into the cache. if `expire` is set to zero it will default to 24h Set(key string, value interface{}, expire time.Duration) error // Delete object from cache Delete(key string) error }
CacheStorage allows the caller to set, get and delete items in the cache. Cached items are stored as byte arrays and marshalled using "encoding/gob" so any struct added to the cache needs to be registered with `remotecache.Register` ex `remotecache.Register(CacheableStruct{})“
type RemoteCache ¶
type RemoteCache struct { SQLStore *sqlstore.SqlStore `inject:""` Cfg *setting.Cfg `inject:""` // contains filtered or unexported fields }
RemoteCache allows Grafana to cache data outside its own process
func NewFakeStore ¶
func NewFakeStore(t *testing.T) *RemoteCache
NewFakeStore creates store for testing
func (*RemoteCache) Delete ¶
func (ds *RemoteCache) Delete(key string) error
Delete object from cache
func (*RemoteCache) Get ¶
func (ds *RemoteCache) Get(key string) (interface{}, error)
Get reads object from Cache