feat: 请求日志记录
This commit is contained in:
@@ -16,34 +16,28 @@ type Message struct {
|
||||
|
||||
// Subscription represents an active subscription to a pub/sub channel.
|
||||
type Subscription interface {
|
||||
// Channel returns the channel for receiving messages.
|
||||
Channel() <-chan *Message
|
||||
// Close unsubscribes and releases any resources associated with the subscription.
|
||||
Close() error
|
||||
}
|
||||
|
||||
// Store is a generic key-value store interface.
|
||||
// Implementations of this interface must be safe for concurrent use.
|
||||
type Store interface {
|
||||
// Set stores a key-value pair with an optional TTL.
|
||||
// - key: The key (string).
|
||||
// - value: The value ([]byte).
|
||||
// - ttl: The expiration time. If ttl is 0, the key never expires.
|
||||
Set(key string, value []byte, ttl time.Duration) error
|
||||
|
||||
// Get retrieves a value by its key.
|
||||
// It must return store.ErrNotFound if the key does not exist.
|
||||
Get(key string) ([]byte, error)
|
||||
|
||||
// Delete removes a value by its key.
|
||||
// If the key does not exist, this operation should be considered successful (idempotent) and not return an error.
|
||||
Delete(key string) error
|
||||
|
||||
// Del deletes multiple keys.
|
||||
Del(keys ...string) error
|
||||
|
||||
// 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
|
||||
@@ -56,6 +50,10 @@ type Store interface {
|
||||
LRem(key string, count int64, value any) error
|
||||
Rotate(key string) (string, error)
|
||||
|
||||
// SET operations
|
||||
SAdd(key string, members ...any) error
|
||||
SPopN(key string, count int64) ([]string, error)
|
||||
|
||||
// Close closes the store and releases any underlying resources.
|
||||
Close() error
|
||||
|
||||
@@ -63,7 +61,6 @@ type Store interface {
|
||||
Publish(channel string, message []byte) error
|
||||
|
||||
// Subscribe listens for messages on a given channel.
|
||||
// It returns a Subscription object that can be used to receive messages and to close the subscription.
|
||||
Subscribe(channel string) (Subscription, error)
|
||||
}
|
||||
|
||||
@@ -80,5 +77,5 @@ type RedisPipeliner interface {
|
||||
|
||||
// LuaScripter is an optional interface that a Store can implement to provide Lua script execution.
|
||||
type LuaScripter interface {
|
||||
Eval(script string, keys []string, args ...interface{}) (interface{}, error)
|
||||
Eval(script string, keys []string, args ...any) (any, error)
|
||||
}
|
||||
|
Reference in New Issue
Block a user