feat: key provider

This commit is contained in:
tbphp
2025-07-07 18:55:06 +08:00
parent 3228cdad64
commit 747f130f7e
9 changed files with 831 additions and 141 deletions

View File

@@ -28,6 +28,31 @@ type Store interface {
// Exists checks if a key exists in the store.
Exists(key string) (bool, error)
// SetNX sets a key-value pair if the key does not already exist.
// It returns true if the key was set, false otherwise.
SetNX(key string, value []byte, ttl time.Duration) (bool, error)
// HASH operations
HSet(key, field string, value any) error
HGetAll(key string) (map[string]string, error)
HIncrBy(key, field string, incr int64) (int64, error)
// LIST operations
LPush(key string, values ...any) error
LRem(key string, count int64, value any) error
Rotate(key string) (string, error)
// Close closes the store and releases any underlying resources.
Close() error
}
// Pipeliner defines an interface for executing a batch of commands.
type Pipeliner interface {
HSet(key string, values map[string]any)
Exec() error
}
// RedisPipeliner is an optional interface that a Store can implement to provide pipelining.
type RedisPipeliner interface {
Pipeline() Pipeliner
}