diff options
author | Valery Piashchynski <[email protected]> | 2021-01-07 15:53:11 +0300 |
---|---|---|
committer | GitHub <[email protected]> | 2021-01-07 15:53:11 +0300 |
commit | ac71c41bec81fcb457e2ad18f4cbaa3f4b99d6c4 (patch) | |
tree | 5d42ca5aecf65609ebaabc517c1368d43dbce179 /plugins/kv/interface.go | |
parent | 984953a9db1d94817bda2e3d9266583151b1b437 (diff) | |
parent | 74405558a4a5bafefd081553f70d85943e9a3a37 (diff) |
Merge pull request #468 from spiral/plugin/kv
Plugin/kv
Diffstat (limited to 'plugins/kv/interface.go')
-rw-r--r-- | plugins/kv/interface.go | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/plugins/kv/interface.go b/plugins/kv/interface.go new file mode 100644 index 00000000..c1367cdf --- /dev/null +++ b/plugins/kv/interface.go @@ -0,0 +1,41 @@ +package kv + +// Item represents general storage item +type Item struct { + // Key of item + Key string + // Value of item + Value string + // live until time provided by TTL in RFC 3339 format + TTL string +} + +// Storage represents single abstract storage. +type Storage interface { + // Has checks if value exists. + Has(keys ...string) (map[string]bool, error) + + // Get loads value content into a byte slice. + Get(key string) ([]byte, error) + + // MGet loads content of multiple values + // Returns the map with existing keys and associated values + MGet(keys ...string) (map[string]interface{}, error) + + // Set used to upload item to KV with TTL + // 0 value in TTL means no TTL + Set(items ...Item) error + + // MExpire sets the TTL for multiply keys + MExpire(items ...Item) error + + // TTL return the rest time to live for provided keys + // Not supported for the memcached and boltdb + TTL(keys ...string) (map[string]interface{}, error) + + // Delete one or multiple keys. + Delete(keys ...string) error + + // Close closes the storage and underlying resources. + Close() error +} |