MCPcopy Create free account
hub / github.com/GoogleChrome/webstatus.dev / Get

Method Get

lib/valkeycache/cache.go:101–115  ·  view source on GitHub ↗

Get retrieves a value from the cache. It returns cachetypes.ErrCachedDataNotFound if it does not exist. nolint: ireturn // V is not a interface always. Can ignore this.

(
	ctx context.Context,
	key K,
)

Source from the content-addressed store, hash-verified

99// It returns cachetypes.ErrCachedDataNotFound if it does not exist.
100// nolint: ireturn // V is not a interface always. Can ignore this.
101func (c *ValkeyDataCache[K, V]) Get(
102 ctx context.Context,
103 key K,
104) (V, error) {
105 defaultValue := *new(V)
106 msg, err := c.client.Do(ctx, c.client.B().Get().Key(c.cacheKey(key)).Build()).ToMessage()
107 if errors.Is(err, valkey.Nil) {
108 return defaultValue, cachetypes.ErrCachedDataNotFound
109 } else if err != nil {
110 // All other errors
111 return defaultValue, err
112 }
113
114 return msg.AsBytes()
115}

Callers

nothing calls this directly

Calls 4

cacheKeyMethod · 0.95
DoMethod · 0.65
GetMethod · 0.65
BuildMethod · 0.45

Tested by

no test coverage detected