MCPcopy Create free account
hub / github.com/pace/bricks / Cache

Interface Cache

pkg/cache/cache.go:11–26  ·  view source on GitHub ↗

Cache is a common abstraction to cache bytes. It is safe for concurrent use.

Source from the content-addressed store, hash-verified

9
10// Cache is a common abstraction to cache bytes. It is safe for concurrent use.
11type Cache interface {
12 // Put stores the value under the key. Any existing value is overwritten. If
13 // ttl is given, the cache automatically forgets the value after the
14 // duration. If ttl is zero then it is never automatically forgotten.
15 Put(ctx context.Context, key string, value []byte, ttl time.Duration) error
16
17 // Get returns the value stored under the key and its remaining ttl. If
18 // there is no value stored, ErrNotFound is returned. If the ttl is zero,
19 // the value does not automatically expire. Unless an error is returned, the
20 // value is always non-nil.
21 Get(ctx context.Context, key string) (value []byte, ttl time.Duration, _ error)
22
23 // Forget removes the value stored under the key. No error is returned if
24 // there is no value stored.
25 Forget(ctx context.Context, key string) error
26}

Callers 17

Example_inMemoryFunction · 0.95
HealthCheckMethod · 0.65
TestPutMethod · 0.65
TestGetMethod · 0.65
TestForgetMethod · 0.65
Example_inMemoryFunction · 0.95
mainFunction · 0.65
handler.goFile · 0.65
ProxyAwareRemoteFunction · 0.65
RequestIDHandlerFunction · 0.65
UserAgentHandlerFunction · 0.65
RefererHandlerFunction · 0.65

Implementers 2

Redispkg/cache/redis.go
Memorypkg/cache/memory.go

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…