Documentation
¶
Index ¶
- Variables
- type Client
- func (c *Client) Close() error
- func (c *Client) Decrement(ctx context.Context, key string, value int64) (int64, error)
- func (c *Client) Delete(ctx context.Context, keys ...string) error
- func (c *Client) Exists(ctx context.Context, keys ...string) (bool, error)
- func (c *Client) Expire(ctx context.Context, key string, expiration time.Duration) error
- func (c *Client) Get(ctx context.Context, key string) (string, error)
- func (c *Client) GetBytes(ctx context.Context, key string) ([]byte, error)
- func (c *Client) GetJSON(ctx context.Context, key string, dest interface{}) error
- func (c *Client) HDel(ctx context.Context, key string, fields ...string) error
- func (c *Client) HGet(ctx context.Context, key string, field string) (string, error)
- func (c *Client) HGetAll(ctx context.Context, key string) (map[string]string, error)
- func (c *Client) HMSet(ctx context.Context, key string, pairs ...interface{}) error
- func (c *Client) HSet(ctx context.Context, key string, field string, value interface{}) error
- func (c *Client) Increment(ctx context.Context, key string, value int64) (int64, error)
- func (c *Client) Keys(ctx context.Context, pattern string) ([]string, error)
- func (c *Client) LLen(ctx context.Context, key string) (int64, error)
- func (c *Client) LPop(ctx context.Context, key string) (string, error)
- func (c *Client) LPush(ctx context.Context, key string, values ...interface{}) error
- func (c *Client) LRange(ctx context.Context, key string, start, stop int64) ([]string, error)
- func (c *Client) MGet(ctx context.Context, keys ...string) ([]interface{}, error)
- func (c *Client) MSet(ctx context.Context, pairs ...interface{}) error
- func (c *Client) Ping(ctx context.Context) error
- func (c *Client) Publish(ctx context.Context, channel string, message interface{}) error
- func (c *Client) RPop(ctx context.Context, key string) (string, error)
- func (c *Client) RPush(ctx context.Context, key string, values ...interface{}) error
- func (c *Client) SAdd(ctx context.Context, key string, members ...interface{}) error
- func (c *Client) SIsMember(ctx context.Context, key string, member interface{}) (bool, error)
- func (c *Client) SMembers(ctx context.Context, key string) ([]string, error)
- func (c *Client) SRem(ctx context.Context, key string, members ...interface{}) error
- func (c *Client) Scan(ctx context.Context, cursor uint64, match string, count int64) ([]string, uint64, error)
- func (c *Client) Set(ctx context.Context, key string, value interface{}, expiration time.Duration) error
- func (c *Client) SetJSON(ctx context.Context, key string, value interface{}, expiration time.Duration) error
- func (c *Client) SetNX(ctx context.Context, key string, value interface{}, expiration time.Duration) (bool, error)
- func (c *Client) SetXX(ctx context.Context, key string, value interface{}, expiration time.Duration) (bool, error)
- func (c *Client) Stats() *redis.PoolStats
- func (c *Client) Subscribe(ctx context.Context, channels ...string) *redis.PubSub
- func (c *Client) TTL(ctx context.Context, key string) (time.Duration, error)
- func (c *Client) ZAdd(ctx context.Context, key string, members ...redis.Z) error
- func (c *Client) ZRange(ctx context.Context, key string, start, stop int64) ([]string, error)
- func (c *Client) ZRangeByScore(ctx context.Context, key string, min, max string) ([]string, error)
- func (c *Client) ZRem(ctx context.Context, key string, members ...interface{}) error
- type Option
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrKeyNotFound indicates a key does not exist in Redis ErrKeyNotFound = errors.New("key not found") // ErrConnectionFailed indicates a failed connection attempt ErrConnectionFailed = errors.New("connection failed") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client wraps the go-redis client with helper methods
func (*Client) Scan ¶
func (c *Client) Scan(ctx context.Context, cursor uint64, match string, count int64) ([]string, uint64, error)
Scan iterates over keys matching a pattern (safer than Keys for large datasets)
func (*Client) Set ¶
func (c *Client) Set(ctx context.Context, key string, value interface{}, expiration time.Duration) error
Set stores a key-value pair with expiration
func (*Client) SetJSON ¶
func (c *Client) SetJSON(ctx context.Context, key string, value interface{}, expiration time.Duration) error
SetJSON stores a JSON-serialized value with expiration
func (*Client) SetNX ¶
func (c *Client) SetNX(ctx context.Context, key string, value interface{}, expiration time.Duration) (bool, error)
SetNX sets a key only if it doesn't already exist (atomic operation)
func (*Client) SetXX ¶
func (c *Client) SetXX(ctx context.Context, key string, value interface{}, expiration time.Duration) (bool, error)
SetXX sets a key only if it already exists (atomic operation)
func (*Client) ZRangeByScore ¶
ZRangeByScore returns elements from a sorted set by score range
type Option ¶
Option configures the Redis client
func WithMaxRetries ¶
WithMaxRetries sets the maximum number of retries
func WithMinIdleConns ¶
WithMinIdleConns sets the minimum idle connections
func WithTimeout ¶
WithTimeout sets dial, read, and write timeouts
Click to show internal directories.
Click to hide internal directories.