Documentation ¶
Index ¶
- Constants
- Variables
- type CacheData
- type CacheStorage
- type FakeCacheStorage
- func (fcs FakeCacheStorage) Count(_ context.Context, prefix string) (int64, error)
- func (fcs FakeCacheStorage) Delete(_ context.Context, key string) error
- func (fcs FakeCacheStorage) Get(_ context.Context, key string) ([]byte, error)
- func (fcs FakeCacheStorage) Set(_ context.Context, key string, value []byte, exp time.Duration) error
- type RemoteCache
- func (ds *RemoteCache) Count(ctx context.Context, prefix string) (int64, error)
- func (ds *RemoteCache) Delete(ctx context.Context, key string) error
- func (ds *RemoteCache) Get(ctx context.Context, key string) ([]byte, error)
- func (ds *RemoteCache) Run(ctx context.Context) error
- func (ds *RemoteCache) Set(ctx context.Context, key string, value []byte, expire time.Duration) error
Constants ¶
View Source
const (
ServiceName = "RemoteCache"
)
Variables ¶
View Source
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") )
View Source
var ErrNotImplemented = errors.New("not implemented")
Functions ¶
This section is empty.
Types ¶
type CacheStorage ¶
type CacheStorage interface { // Get gets the cache value as an byte array Get(ctx context.Context, key string) ([]byte, error) // Set saves the value as an byte array. if `expire` is set to zero it will default to 24h Set(ctx context.Context, key string, value []byte, expire time.Duration) error // Delete object from cache Delete(ctx context.Context, key string) error // Count returns the number of items in the cache. // Optionaly a prefix can be provided to only count items with that prefix // DO NOT USE. Not available for memcached. Count(ctx context.Context, prefix string) (int64, 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{})`
func NewFakeCacheStorage ¶
func NewFakeCacheStorage() CacheStorage
type FakeCacheStorage ¶
func (FakeCacheStorage) Delete ¶
func (fcs FakeCacheStorage) Delete(_ context.Context, key string) error
type RemoteCache ¶
type RemoteCache struct { SQLStore db.DB 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 ProvideService(cfg *setting.Cfg, sqlStore db.DB, usageStats usagestats.Service, secretsService secrets.Service) (*RemoteCache, error)
func (*RemoteCache) Delete ¶
func (ds *RemoteCache) Delete(ctx context.Context, key string) error
Delete object from cache
Click to show internal directories.
Click to hide internal directories.