Files
grafana/pkg/infra/remotecache/test_utils.go
Karl Persson d93f5bab83 RemoteCache: remove count method (#91581)
* remove count method

* remove count from remote cache

---------

Co-authored-by: jguer <me@jguer.space>
2024-08-06 19:21:00 +02:00

36 lines
671 B
Go

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 NewFakeCacheStorage() FakeCacheStorage {
return FakeCacheStorage{
Storage: map[string][]byte{},
}
}