Documentation ¶
Index ¶
- Constants
- Variables
- func Register(value interface{})
- type CacheData
- type CacheStorage
- type RemoteCache
- func (ds *RemoteCache) Delete(ctx context.Context, key string) error
- func (ds *RemoteCache) Get(ctx context.Context, key string) (interface{}, error)
- func (ds *RemoteCache) Run(ctx context.Context) error
- func (ds *RemoteCache) Set(ctx context.Context, key string, value interface{}, expire time.Duration) error
Constants ¶
const (
ServiceName = "RemoteCache"
)
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(ctx context.Context, key string) (interface{}, error) // Set sets an object into the cache. if `expire` is set to zero it will default to 24h Set(ctx context.Context, key string, value interface{}, expire time.Duration) error // Delete object from cache Delete(ctx context.Context, 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 Cfg *setting.Cfg // 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 ProvideService ¶
func (*RemoteCache) Delete ¶
func (ds *RemoteCache) Delete(ctx context.Context, key string) error
Delete object from cache
func (*RemoteCache) Get ¶
func (ds *RemoteCache) Get(ctx context.Context, key string) (interface{}, error)
Get reads object from Cache