RedisFromContext returns the request's Redis client from the context, or nil if not set.
(ctx stdctx.Context)
| 55 | |
| 56 | // RedisFromContext returns the request's Redis client from the context, or nil if not set. |
| 57 | func RedisFromContext(ctx stdctx.Context) *redis.Client { |
| 58 | v := ctx.Value(redisContextKey) |
| 59 | if v == nil { |
| 60 | return nil |
| 61 | } |
| 62 | rdb, _ := v.(*redis.Client) |
| 63 | return rdb |
| 64 | } |
| 65 | |
| 66 | // RedisResolver resolves the Redis client for a request: client from context, or default. |
| 67 | // Pass to stores so they use the correct Redis client per request. |