github.com/clubpay/ronykit/kit@v0.14.4-0.20240515065620-d0dace45cbc7/ctx_store.go (about) 1 package kit 2 3 import "time" 4 5 // Store identifies a key-value store, which its value doesn't have any limitation. 6 type Store interface { 7 Get(key string) any 8 Exists(key string) bool 9 Set(key string, val any) 10 Delete(key string) 11 Scan(prefix string, cb func(key string) bool) 12 } 13 14 // ClusterStore identifies a key-value store, which its key-value pairs are shared between 15 // different instances of the cluster. Also, the value type is only string. 16 type ClusterStore interface { 17 // Set creates/updates a key-value pair in the cluster 18 Set(key, value string, ttl time.Duration) error 19 // Delete deletes the key-value pair from the cluster 20 Delete(key string) error 21 // Get returns the value bind to the key 22 Get(key string) (string, error) 23 // Scan scans through the keys which have the prefix. 24 // If callback returns `false`, then the scan is aborted. 25 Scan(prefix string, cb func(string) bool) error 26 ScanWithValue(prefix string, cb func(string, string) bool) error 27 }