summaryrefslogtreecommitdiff
path: root/plugins/kv/interface.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-01-05 17:37:17 +0300
committerValery Piashchynski <[email protected]>2021-01-05 17:37:17 +0300
commit13b01ccaba1eedeb99d37842ec8f2019d2625187 (patch)
treec645c240336666fa63d70ed2703a78df828c597f /plugins/kv/interface.go
parent877b0ed461c7d5e1de87b7561f414aeb236cf3ec (diff)
Finish implementation of the KV
Diffstat (limited to 'plugins/kv/interface.go')
-rw-r--r--plugins/kv/interface.go45
1 files changed, 45 insertions, 0 deletions
diff --git a/plugins/kv/interface.go b/plugins/kv/interface.go
new file mode 100644
index 00000000..f17754e6
--- /dev/null
+++ b/plugins/kv/interface.go
@@ -0,0 +1,45 @@
+package kv
+
+// Item represents general storage item
+import (
+ "context"
+)
+
+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(ctx context.Context, keys ...string) (map[string]bool, error)
+
+ // Get loads value content into a byte slice.
+ Get(ctx context.Context, key string) ([]byte, error)
+
+ // MGet loads content of multiple values
+ // If there are no values for keys, key will no be in the map
+ MGet(ctx context.Context, keys ...string) (map[string]interface{}, error)
+
+ // Set used to upload item to KV with TTL
+ // 0 value in TTL means no TTL
+ Set(ctx context.Context, items ...Item) error
+
+ // MExpire sets the TTL for multiply keys
+ MExpire(ctx context.Context, items ...Item) error
+
+ // TTL return the rest time to live for provided keys
+ // Not supported for the memcached and boltdb
+ TTL(ctx context.Context, keys ...string) (map[string]interface{}, error)
+
+ // Delete one or multiple keys.
+ Delete(ctx context.Context, keys ...string) error
+
+ // Close closes the storage and underlying resources.
+ Close() error
+} \ No newline at end of file