MCPcopy
hub / github.com/grafana/dskit / Cache

Interface Cache

cache/cache.go:26–62  ·  cache/cache.go::Cache

Cache is a high level interface to interact with a cache.

Source from the content-addressed store, hash-verified

24
25// Cache is a high level interface to interact with a cache.
26type Cache interface {
27 // GetMulti fetches multiple keys at once from a cache. In case of error,
28 // an empty map is returned and the error tracked/logged. One or more Option
29 // instances may be passed to modify the behavior of this GetMulti call.
30 GetMulti(ctx context.Context, keys []string, opts ...Option) map[string][]byte
31
32 // GetMultiWithError fetches multiple keys at once from a cache and returns an error
33 // if the operation failed. It may return both results and an error if there are only partial
34 // failures. One or more Option instances may be passed to modify the
35 // behavior of this GetMultiWithError call.
36 GetMultiWithError(ctx context.Context, keys []string, opts ...Option) (map[string][]byte, error)
37
38 // SetAsync enqueues an operation to store a key into a cache. In case the underlying
39 // operation fails, the error will be tracked/logged.
40 SetAsync(key string, value []byte, ttl time.Duration)
41
42 // SetMultiAsync enqueues operations to store a keys and values into a cache. In case
43 // any underlying async operations fail, the errors will be tracked/logged.
44 SetMultiAsync(data map[string][]byte, ttl time.Duration)
45
46 // Set stores a key and value into a cache.
47 Set(ctx context.Context, key string, value []byte, ttl time.Duration) error
48
49 // Add stores a key and value into a cache only if it does not already exist. If the
50 // item was not stored because an entry already exists in the cache, ErrNotStored will
51 // be returned.
52 Add(ctx context.Context, key string, value []byte, ttl time.Duration) error
53
54 // Delete deletes a key from a cache.
55 Delete(ctx context.Context, key string) error
56
57 // Stop client and release underlying resources.
58 Stop()
59
60 // Name returns the name of this particular cache instance.
61 Name() string
62}
63
64// Options are used to modify the behavior of an individual call to get results
65// from a cache backend. They are constructed by applying Option callbacks passed

Callers 71

TestMemcachedClient_SetFunction · 0.65
GetMultiMethod · 0.65
GetMultiMethod · 0.65
GetMultiMethod · 0.65
GetMultiWithErrorMethod · 0.65
GetMultiWithErrorMethod · 0.65
GetMultiWithErrorMethod · 0.65

Implementers 7

Versionedcache/versioned.go
MemcachedClientcache/memcached_client.go
LRUCachecache/lru.go
MockCachecache/mock.go
SpanlessTracingCachecache/tracing.go
SnappyCachecache/compression.go

Calls

no outgoing calls

Tested by

no test coverage detected