feat: Initial
This commit is contained in:
commit
1a58b7391e
6 files changed
+63
No files matched your search
Generated
+8
@@ -0,0 +1,8 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
Generated
+8
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/universe_key_value.iml" filepath="$PROJECT_DIR$/.idea/universe_key_value.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Generated
+9
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="WEB_MODULE" version="4">
|
||||||
|
<component name="Go" enabled="true" />
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
Generated
+4
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings" defaultProject="true" />
|
||||||
|
</project>
|
||||||
@@ -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