The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/pkg/infra/remotecache/test_utils.go

39 lines
796 B

package remotecache
import (
"context"
"time"
)
type FakeCacheStorage struct {
Storage map[string][]byte
}
func (fcs FakeCacheStorage) Set(_ context.Context, key string, value []byte, exp time.Duration) error {
fcs.Storage[key] = value
return nil
}
func (fcs FakeCacheStorage) Get(_ context.Context, key string) ([]byte, error) {
value, exist := fcs.Storage[key]
if !exist {
return nil, ErrCacheItemNotFound
}
return value, nil
}
func (fcs FakeCacheStorage) Delete(_ context.Context, key string) error {
delete(fcs.Storage, key)
return nil
}
func (fcs FakeCacheStorage) Count(_ context.Context, prefix string) (int64, error) {
return int64(len(fcs.Storage)), nil
}
func NewFakeCacheStorage() FakeCacheStorage {
return FakeCacheStorage{
Storage: map[string][]byte{},
}
}