set data to storage or memory
(ctx context.Context, key string, raw []byte, exp time.Duration)
| 183 | |
| 184 | // set data to storage or memory |
| 185 | func (m *manager) setRaw(ctx context.Context, key string, raw []byte, exp time.Duration) error { |
| 186 | if m.storage != nil { |
| 187 | if err := m.storage.SetWithContext(ctx, key, raw, exp); err != nil { |
| 188 | return fmt.Errorf("cache: failed to store raw key %q: %w", m.logKey(key), err) |
| 189 | } |
| 190 | return nil |
| 191 | } |
| 192 | |
| 193 | m.memory.Set(key, raw, exp) |
| 194 | return nil |
| 195 | } |
| 196 | |
| 197 | // delete data from storage or memory |
| 198 | func (m *manager) del(ctx context.Context, key string) error { |