Storage interface for communicating with different database/key-value providers
| 8 | // Storage interface for communicating with different database/key-value |
| 9 | // providers |
| 10 | type Storage interface { |
| 11 | // GetWithContext gets the value for the given key with a context. |
| 12 | // `nil, nil` is returned when the key does not exist |
| 13 | GetWithContext(ctx context.Context, key string) ([]byte, error) |
| 14 | |
| 15 | // Get gets the value for the given key. |
| 16 | // `nil, nil` is returned when the key does not exist |
| 17 | Get(key string) ([]byte, error) |
| 18 | |
| 19 | // SetWithContext stores the given value for the given key |
| 20 | // with an expiration value, 0 means no expiration. |
| 21 | // Empty key or value will be ignored without an error. |
| 22 | SetWithContext(ctx context.Context, key string, val []byte, exp time.Duration) error |
| 23 | |
| 24 | // Set stores the given value for the given key along |
| 25 | // with an expiration value, 0 means no expiration. |
| 26 | // Empty key or value will be ignored without an error. |
| 27 | Set(key string, val []byte, exp time.Duration) error |
| 28 | |
| 29 | // DeleteWithContext deletes the value for the given key with a context. |
| 30 | // It returns no error if the storage does not contain the key, |
| 31 | DeleteWithContext(ctx context.Context, key string) error |
| 32 | |
| 33 | // Delete deletes the value for the given key. |
| 34 | // It returns no error if the storage does not contain the key, |
| 35 | Delete(key string) error |
| 36 | |
| 37 | // ResetWithContext resets the storage and deletes all keys with a context. |
| 38 | ResetWithContext(ctx context.Context) error |
| 39 | |
| 40 | // Reset resets the storage and delete all keys. |
| 41 | Reset() error |
| 42 | |
| 43 | // Close closes the storage and will stop any running garbage |
| 44 | // collectors and open connections. |
| 45 | Close() error |
| 46 | } |
no outgoing calls
no test coverage detected