feat: Initial
This commit is contained in:
commit
1a58b7391e
6 files changed
+63
No files matched your search
@@ -0,0 +1,31 @@
|
||||
package universe_key_value
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Capability uint8
|
||||
|
||||
const (
|
||||
CapabilityTTL Capability = iota
|
||||
)
|
||||
|
||||
type KeyValueProvider interface {
|
||||
HasCapability(capability Capability) bool
|
||||
|
||||
ProvideBinary(prefix string) (KeyValueStoreBinary, error)
|
||||
ProvideString(prefix string) (KeyValueStoreString, error)
|
||||
}
|
||||
|
||||
type KeyValueStore[T any] interface {
|
||||
HasCapability(capability Capability) bool
|
||||
|
||||
Get(ctx context.Context, key string) (T, error)
|
||||
Set(ctx context.Context, key string, value T) error
|
||||
SetWithExpiration(ctx context.Context, key string, value T, expiresAt time.Time) error
|
||||
Remove(ctx context.Context, key string) error
|
||||
}
|
||||
|
||||
type KeyValueStoreBinary KeyValueStore[[]byte]
|
||||
type KeyValueStoreString KeyValueStore[string]
|
||||
Reference in new issue
Block a user