initial commit
This commit is contained in:
41
pkg/store/store.go
Normal file
41
pkg/store/store.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Store[V any] interface {
|
||||
// Get retrieves a value from store by key
|
||||
Get(ctx context.Context, key string) (V, bool, error)
|
||||
|
||||
// Set stores a value in store with expiration
|
||||
Set(ctx context.Context, key string, value V, expiration time.Duration) error
|
||||
|
||||
// Delete removes a key from store
|
||||
Delete(ctx context.Context, key string) error
|
||||
|
||||
// Exists checks if a key exists in store
|
||||
Exists(ctx context.Context, key string) (bool, error)
|
||||
|
||||
// SetNX sets a value only if the key doesn't exist (atomic operation)
|
||||
SetNX(ctx context.Context, key string, value V, expiration time.Duration) (bool, error)
|
||||
|
||||
// HMGet retrieves multiple fields from a hash
|
||||
HMGet(ctx context.Context, key string, fields ...string) (map[string]V, error)
|
||||
|
||||
// HGetAll retrieves all available fields from a hash
|
||||
HGetAll(ctx context.Context, key string) (map[string]V, error)
|
||||
|
||||
// HMSet sets multiple fields in a hash with expiration
|
||||
HMSet(ctx context.Context, key string, values map[string]V, expiration time.Duration) error
|
||||
|
||||
// SetMultiple stores multiple key-value pairs with expiration
|
||||
SetMultiple(ctx context.Context, items map[string]V, expiration time.Duration) error
|
||||
|
||||
// DeleteMultiple removes multiple keys from store
|
||||
DeleteMultiple(ctx context.Context, keys ...string) error
|
||||
|
||||
// DeletePattern removes all keys matching the pattern from store
|
||||
DeletePattern(ctx context.Context, pattern string) error
|
||||
}
|
||||
Reference in New Issue
Block a user