Set one value
(ctx context.Context, key string, val interface{}, expiration time.Duration)
| 238 | |
| 239 | // Set one value |
| 240 | func (c *redisClusterCache) Set(ctx context.Context, key string, val interface{}, expiration time.Duration) error { |
| 241 | buf, err := encoding.Marshal(c.encoding, val) |
| 242 | if err != nil { |
| 243 | return fmt.Errorf("encoding.Marshal error: %v, key=%s, val=%+v ", err, key, val) |
| 244 | } |
| 245 | |
| 246 | cacheKey, err := BuildCacheKey(c.KeyPrefix, key) |
| 247 | if err != nil { |
| 248 | return fmt.Errorf("BuildCacheKey error: %v, key=%s", err, key) |
| 249 | } |
| 250 | //if expiration == 0 { |
| 251 | // expiration = DefaultExpireTime |
| 252 | //} |
| 253 | if len(buf) == 0 { |
| 254 | buf = NotFoundPlaceholderBytes |
| 255 | } |
| 256 | err = c.client.Set(ctx, cacheKey, buf, expiration).Err() |
| 257 | if err != nil { |
| 258 | return fmt.Errorf("c.client.Set error: %v, cacheKey=%s", err, cacheKey) |
| 259 | } |
| 260 | return nil |
| 261 | } |
| 262 | |
| 263 | // Get one value |
| 264 | func (c *redisClusterCache) Get(ctx context.Context, key string, val interface{}) error { |
nothing calls this directly
no test coverage detected