summaryrefslogtreecommitdiff
path: root/plugins/kv/interface.go
blob: 7841f9a2ddecf28667e89ad37372b15a61384ca8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package kv

import kvv1 "github.com/spiral/roadrunner/v2/pkg/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]interface{}, 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]interface{}, error)

	// Delete one or multiple keys.
	Delete(keys ...string) error
}

// StorageDriver interface provide storage
type StorageDriver interface {
	Provider
}

// Provider provides storage based on the config
type Provider interface {
	// Provide provides Storage based on the config key
	Provide(key string) (Storage, error)
}