Documentation
¶
Index ¶
- Variables
- type Config
- type RedisStore
- func (s *RedisStore) Clear(ctx context.Context) error
- func (s *RedisStore) Close() error
- func (s *RedisStore) Delete(ctx context.Context, key string) error
- func (s *RedisStore) Get(ctx context.Context, key string) ([]byte, error)
- func (s *RedisStore) Set(ctx context.Context, key string, value []byte, ttl time.Duration) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidClient is returned when Client is nil. ErrInvalidClient = errors.New("redis: Client must not be nil") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Client is the Rueidis client (REQUIRED, must not be nil).
Client rueidis.Client
// KeyPrefix is the prefix for all keys (OPTIONAL).
// Default: empty (no prefix)
KeyPrefix string
// ClientSideCaching enables client-side caching (OPTIONAL).
// Default: false
ClientSideCaching bool
}
Config holds configuration for RedisStore.
type RedisStore ¶
type RedisStore struct {
// contains filtered or unexported fields
}
RedisStore is a Redis-backed cache store using Rueidis client. Thread-safe for concurrent use.
Reference: .references/seaguest-cache/redis_cache.go (Redis operations) Reference: .references/gookit-cache/goredis/goredis.go (Redis client wrapper)
func New ¶
func New(cfg Config) (*RedisStore, error)
New creates a new RedisStore with the given configuration. Returns an error if the configuration is invalid.
func NewWithClient
deprecated
func NewWithClient(client rueidis.Client) *RedisStore
NewWithClient creates a new RedisStore with the given Rueidis client.
Deprecated: Use New with Config instead.
func NewWithPrefix
deprecated
func NewWithPrefix(client rueidis.Client, prefix string) *RedisStore
NewWithPrefix creates a new RedisStore with a key prefix.
Deprecated: Use New with Config instead.
func (*RedisStore) Clear ¶
func (s *RedisStore) Clear(ctx context.Context) error
Clear removes all entries from Redis. If a prefix is set, only keys with that prefix are removed. Otherwise, FLUSHDB is used to clear the entire database.
Reference: .references/gookit-cache/goredis/goredis.go:87 (Clear method)
func (*RedisStore) Close ¶
func (s *RedisStore) Close() error
Close releases resources associated with the Redis client. Idempotent - safe to call multiple times.
func (*RedisStore) Delete ¶
func (s *RedisStore) Delete(ctx context.Context, key string) error
Delete removes a value from Redis. Idempotent - deleting a non-existent key returns nil.
Reference: .references/seaguest-cache/redis_cache.go:82 (delete method)
func (*RedisStore) Get ¶
Get retrieves a value from Redis by key. Returns cache.ErrNotFound if the key doesn't exist.
Reference: .references/seaguest-cache/redis_cache.go:29 (get method)