Documentation
¶
Index ¶
- func LoadAllScripts(ctx context.Context, c *Client) error
- type Client
- func (c *Client) Close()
- func (c *Client) DBSize(ctx context.Context) (int64, error)
- func (c *Client) Del(ctx context.Context, keys ...string) (int64, error)
- func (c *Client) Expire(ctx context.Context, key string, ttl time.Duration) (bool, error)
- func (c *Client) FlushDB(ctx context.Context) error
- func (c *Client) GeoAdd(ctx context.Context, key string, longitude, latitude float64, member string) error
- func (c *Client) GeoPos(ctx context.Context, key string, members ...string) ([]*GeoPosition, error)
- func (c *Client) Get(ctx context.Context, key string) (string, error)
- func (c *Client) GetKeyMetadata(ctx context.Context, key string) (*KeyMetadata, error)
- func (c *Client) GetMemoryStats(ctx context.Context) (*MemoryStats, error)
- func (c *Client) GetNotifyKeyspaceEvents(ctx context.Context) (string, error)
- func (c *Client) HDel(ctx context.Context, key string, fields ...string) error
- func (c *Client) HExists(ctx context.Context, key, field string) (bool, error)
- func (c *Client) HGetAll(ctx context.Context, key string) (map[string]string, error)
- func (c *Client) HLen(ctx context.Context, key string) (int64, error)
- func (c *Client) HRename(ctx context.Context, key, oldField, newField string) (string, error)
- func (c *Client) HScan(ctx context.Context, key string, cursor uint64, count int64) (map[string]string, uint64, error)
- func (c *Client) HSet(ctx context.Context, key, field, value string) error
- func (c *Client) IncrByFloat(ctx context.Context, key string, amount float64) (string, error)
- func (c *Client) Info(ctx context.Context, section string) (string, error)
- func (c *Client) Keys(ctx context.Context, pattern string, cursor uint64, count int64) ([]string, uint64, error)
- func (c *Client) LLen(ctx context.Context, key string) (int64, error)
- func (c *Client) LPush(ctx context.Context, key string, values ...string) error
- func (c *Client) LRange(ctx context.Context, key string, start, stop int64) ([]string, error)
- func (c *Client) LRemByIndex(ctx context.Context, key string, index int64) error
- func (c *Client) LSet(ctx context.Context, key string, index int64, value string) error
- func (c *Client) PFAdd(ctx context.Context, key string, elements ...string) error
- func (c *Client) PFCount(ctx context.Context, key string) (int64, error)
- func (c *Client) Persist(ctx context.Context, key string) (bool, error)
- func (c *Client) Ping(ctx context.Context) error
- func (c *Client) RPush(ctx context.Context, key string, values ...string) error
- func (c *Client) Raw() valkey.Client
- func (c *Client) Rename(ctx context.Context, key, newkey string) error
- func (c *Client) SAdd(ctx context.Context, key string, members ...string) error
- func (c *Client) SAddIfNotExists(ctx context.Context, key, member string) (bool, error)
- func (c *Client) SCard(ctx context.Context, key string) (int64, error)
- func (c *Client) SIsMember(ctx context.Context, key string, member string) (bool, error)
- func (c *Client) SMembers(ctx context.Context, key string) ([]string, error)
- func (c *Client) SRem(ctx context.Context, key string, members ...string) error
- func (c *Client) SRename(ctx context.Context, key, oldMember, newMember string) error
- func (c *Client) SScan(ctx context.Context, key string, cursor uint64, count int64) ([]string, uint64, error)
- func (c *Client) Set(ctx context.Context, key, value string, ttl time.Duration) error
- func (c *Client) SetNotifyKeyspaceEvents(ctx context.Context, value string) error
- func (c *Client) SubscribeKeyspace(ctx context.Context, db int) (<-chan KeyEvent, error)
- func (c *Client) TTL(ctx context.Context, key string) (int64, error)
- func (c *Client) Type(ctx context.Context, key string) (string, error)
- func (c *Client) XAddMulti(ctx context.Context, key string, fields map[string]string) (string, error)
- func (c *Client) XDel(ctx context.Context, key string, ids ...string) (int64, error)
- func (c *Client) XLen(ctx context.Context, key string) (int64, error)
- func (c *Client) XRange(ctx context.Context, key, start, stop string, count int64) ([]StreamEntry, error)
- func (c *Client) XRangePage(ctx context.Context, key string, startAfterID string, pageSize int64) ([]StreamEntry, string, error)
- func (c *Client) ZAdd(ctx context.Context, key string, member string, score float64) error
- func (c *Client) ZCard(ctx context.Context, key string) (int64, error)
- func (c *Client) ZIncrBy(ctx context.Context, key string, member string, amount float64) (float64, error)
- func (c *Client) ZRangeWithScores(ctx context.Context, key string, start, stop int64) ([]ZMember, error)
- func (c *Client) ZRem(ctx context.Context, key string, members ...string) error
- func (c *Client) ZRename(ctx context.Context, key, oldMember, newMember string) (float64, error)
- type GeoMember
- type GeoPosition
- type KeyEvent
- type KeyMetadata
- type MemoryStats
- type Script
- type StreamEntry
- type ZMember
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the Valkey client with application-specific methods
func (*Client) GeoAdd ¶
func (c *Client) GeoAdd(ctx context.Context, key string, longitude, latitude float64, member string) error
GeoAdd adds a member with coordinates to a geospatial index
func (*Client) GeoPos ¶
GeoPos returns the coordinates of members in a geospatial index Returns nil for members that don't exist
func (*Client) GetKeyMetadata ¶
GetKeyMetadata atomically retrieves key type, size, and TTL Returns nil if the key doesn't exist
func (*Client) GetMemoryStats ¶
func (c *Client) GetMemoryStats(ctx context.Context) (*MemoryStats, error)
GetMemoryStats returns memory usage statistics from INFO memory
func (*Client) GetNotifyKeyspaceEvents ¶
GetNotifyKeyspaceEvents returns the current notify-keyspace-events setting
func (*Client) HRename ¶
HRename atomically renames a hash field, preserving its value Returns the value and an error if the old field doesn't exist or the new field already exists
func (*Client) HScan ¶
func (c *Client) HScan(ctx context.Context, key string, cursor uint64, count int64) (map[string]string, uint64, error)
HScan returns fields and values of a hash using cursor-based pagination
func (*Client) IncrByFloat ¶
IncrByFloat increments a key by a float amount (handles both int and float)
func (*Client) Keys ¶
func (c *Client) Keys(ctx context.Context, pattern string, cursor uint64, count int64) ([]string, uint64, error)
Keys returns keys matching the pattern
func (*Client) LRemByIndex ¶
LRemByIndex removes the element at the given index atomically using a Lua script This prevents race conditions where the list could be modified between LSET and LREM
func (*Client) SAddIfNotExists ¶
SAddIfNotExists atomically adds a member to a set only if it doesn't exist Returns true if added, false if already exists
func (*Client) SRename ¶
SRename atomically renames a set member (removes old member, adds new member)
func (*Client) SScan ¶
func (c *Client) SScan(ctx context.Context, key string, cursor uint64, count int64) ([]string, uint64, error)
SScan returns members of a set using cursor-based pagination
func (*Client) SetNotifyKeyspaceEvents ¶
SetNotifyKeyspaceEvents enables/disables keyspace notifications
func (*Client) SubscribeKeyspace ¶
SubscribeKeyspace subscribes to keyspace notifications for a specific database. Returns a channel that emits KeyEvent for each key operation. The channel is closed when the context is cancelled or an error occurs.
func (*Client) TTL ¶
TTL returns the TTL of a key in seconds (-1 if no TTL, -2 if key doesn't exist)
func (*Client) XAddMulti ¶
func (c *Client) XAddMulti(ctx context.Context, key string, fields map[string]string) (string, error)
XAddMulti appends an entry with multiple fields to a stream
func (*Client) XRange ¶
func (c *Client) XRange(ctx context.Context, key, start, stop string, count int64) ([]StreamEntry, error)
XRange returns entries from a stream
func (*Client) XRangePage ¶
func (c *Client) XRangePage(ctx context.Context, key string, startAfterID string, pageSize int64) ([]StreamEntry, string, error)
XRangePage fetches a specific page of stream entries using ID-based pagination startAfterID: if provided, starts after this ID (for cursor-based pagination) If startAfterID is empty, starts from beginning
func (*Client) ZIncrBy ¶
func (c *Client) ZIncrBy(ctx context.Context, key string, member string, amount float64) (float64, error)
ZIncrBy increments the score of a member in a sorted set
func (*Client) ZRangeWithScores ¶
func (c *Client) ZRangeWithScores(ctx context.Context, key string, start, stop int64) ([]ZMember, error)
ZRangeWithScores returns members with scores from a sorted set
type GeoMember ¶
type GeoMember struct {
Member string `json:"member"`
Longitude float64 `json:"longitude"`
Latitude float64 `json:"latitude"`
}
GeoMember represents a member with geographic coordinates
type GeoPosition ¶
GeoPosition represents geographic coordinates
type KeyEvent ¶
type KeyEvent struct {
Operation string // "set", "del", "expire", "expired", "rename_from", "rename_to", etc.
Key string
}
KeyEvent represents a keyspace notification event
type KeyMetadata ¶
KeyMetadata represents metadata about a key
type MemoryStats ¶
MemoryStats represents memory usage statistics
type Script ¶
type Script struct {
// contains filtered or unexported fields
}
Script represents a Lua script that can be executed atomically
type StreamEntry ¶
StreamEntry represents an entry in a stream