Like Prometheus, but for logs.
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.
 
 
 
 
 
 
loki/pkg/storage/chunk/cache/mock.go

56 lines
996 B

package cache
import (
"context"
"sync"
"github.com/grafana/loki/pkg/logqlmodel/stats"
)
type mockCache struct {
sync.Mutex
cache map[string][]byte
}
func (m *mockCache) Store(_ context.Context, keys []string, bufs [][]byte) error {
m.Lock()
defer m.Unlock()
for i := range keys {
m.cache[keys[i]] = bufs[i]
}
return nil
}
func (m *mockCache) Fetch(ctx context.Context, keys []string) (found []string, bufs [][]byte, missing []string, err error) {
m.Lock()
defer m.Unlock()
for _, key := range keys {
buf, ok := m.cache[key]
if ok {
found = append(found, key)
bufs = append(bufs, buf)
} else {
missing = append(missing, key)
}
}
return
}
func (m *mockCache) Stop() {
}
func (m *mockCache) GetCacheType() stats.CacheType {
return "mock"
}
// NewMockCache makes a new MockCache.
func NewMockCache() Cache {
return &mockCache{
cache: map[string][]byte{},
}
}
// NewNoopCache returns a no-op cache.
func NewNoopCache() Cache {
return NewTiered(nil)
}