MCPcopy Index your code
hub / github.com/NdoleStudio/httpsms / Get

Method Get

api/pkg/cache/redis_cache.go:29–41  ·  view source on GitHub ↗

Get an item from the redis cache

(ctx context.Context, key string)

Source from the content-addressed store, hash-verified

27
28// Get an item from the redis cache
29func (cache *redisCache) Get(ctx context.Context, key string) (value string, err error) {
30 ctx, span := cache.tracer.Start(ctx)
31 defer span.End()
32
33 response, err := cache.client.Get(ctx, key).Result()
34 if errors.Is(err, redis.Nil) {
35 return "", stacktrace.Propagate(err, fmt.Sprintf("no item found in redis with key [%s]", key))
36 }
37 if err != nil {
38 return "", stacktrace.Propagate(err, fmt.Sprintf("cannot get item in redis with key [%s]", key))
39 }
40 return response, nil
41}
42
43// Set an item in the redis cache
44func (cache *redisCache) Set(ctx context.Context, key string, value string, ttl time.Duration) error {

Callers

nothing calls this directly

Calls 2

StartMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected