@ -25,6 +25,7 @@ type KVStore interface {
Set ( ctx context . Context , orgId int64 , namespace string , key string , value string ) error
Set ( ctx context . Context , orgId int64 , namespace string , key string , value string ) error
Del ( ctx context . Context , orgId int64 , namespace string , key string ) error
Del ( ctx context . Context , orgId int64 , namespace string , key string ) error
Keys ( ctx context . Context , orgId int64 , namespace string , keyPrefix string ) ( [ ] Key , error )
Keys ( ctx context . Context , orgId int64 , namespace string , keyPrefix string ) ( [ ] Key , error )
GetAll ( ctx context . Context , orgId int64 , namespace string ) ( map [ int64 ] map [ string ] string , error )
}
}
// WithNamespace returns a kvstore wrapper with fixed orgId and namespace.
// WithNamespace returns a kvstore wrapper with fixed orgId and namespace.
@ -58,3 +59,8 @@ func (kv *NamespacedKVStore) Del(ctx context.Context, key string) error {
func ( kv * NamespacedKVStore ) Keys ( ctx context . Context , keyPrefix string ) ( [ ] Key , error ) {
func ( kv * NamespacedKVStore ) Keys ( ctx context . Context , keyPrefix string ) ( [ ] Key , error ) {
return kv . kvStore . Keys ( ctx , kv . orgId , kv . namespace , keyPrefix )
return kv . kvStore . Keys ( ctx , kv . orgId , kv . namespace , keyPrefix )
}
}
// GetAll returns all the keys and values stored per organization. It returns a map of org -> key -> value.
func ( kv * NamespacedKVStore ) GetAll ( ctx context . Context ) ( map [ int64 ] map [ string ] string , error ) {
return kv . kvStore . GetAll ( ctx , kv . orgId , kv . namespace )
}