From 5627146e45afbb8f6566862c60a42a0b0aad2d0a Mon Sep 17 00:00:00 2001 From: Valery Piashchynski Date: Tue, 22 Jun 2021 15:20:08 +0300 Subject: - Move common interfaces and structures to the 'common' folder - Update tests Signed-off-by: Valery Piashchynski --- common/kv/interface.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 common/kv/interface.go (limited to 'common/kv/interface.go') diff --git a/common/kv/interface.go b/common/kv/interface.go new file mode 100644 index 00000000..ffdbbe62 --- /dev/null +++ b/common/kv/interface.go @@ -0,0 +1,36 @@ +package kv + +import kvv1 "github.com/spiral/roadrunner/v2/proto/kv/v1beta" + +// 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][]byte, error) + + // Set used to upload item to KV with TTL + // 0 value in TTL means no TTL + Set(items ...*kvv1.Item) error + + // MExpire sets the TTL for multiply keys + MExpire(items ...*kvv1.Item) error + + // TTL return the rest time to live for provided keys + // Not supported for the memcached and boltdb + TTL(keys ...string) (map[string]string, error) + + // Delete one or multiple keys. + Delete(keys ...string) error +} + +// Constructor provides storage based on the config +type Constructor interface { + // KVConstruct provides Storage based on the config key + KVConstruct(key string) (Storage, error) +} -- cgit v1.2.3