Documentation
¶
Index ¶
- Constants
- Variables
- type Client
- func (c *Client) ClusterNodes() *goredis.StringCmd
- func (c *Client) DeleteHash(key string, fields ...string) *goredis.IntCmd
- func (c *Client) DeleteListElements(key string) *goredis.StringCmd
- func (c *Client) DeleteSet(key string) *goredis.StringCmd
- func (c *Client) DeleteString(key string) *goredis.StringCmd
- func (c *Client) Get(key string) *goredis.StringCmd
- func (c *Client) GetHashVals(key string) *goredis.StringSliceCmd
- func (c *Client) GetListRange(key string, start, end int64) *goredis.StringSliceCmd
- func (c *Client) GetSetMembers(key string) *goredis.StringSliceCmd
- func (c *Client) Info() *goredis.StringCmd
- func (c *Client) Set(key, value string) *goredis.StatusCmd
- func (c *Client) SetAdd(key string, members interface{}) *goredis.IntCmd
- func (c *Client) SetHash(key string, values interface{}) *goredis.IntCmd
- func (c *Client) SetListContents(key string, values interface{}) *goredis.IntCmd
- func (c *Client) SetStringWithExpiry(key string, value string, expiration time.Duration) *goredis.StatusCmd
- type Option
- type RedisConfig
- type SetOption
- type ValkeyCache
- func (c *ValkeyCache) Close()
- func (c *ValkeyCache) Get(ctx context.Context, key string) (string, error)
- func (c *ValkeyCache) LPop(ctx context.Context, key string) (string, error)
- func (c *ValkeyCache) LPush(ctx context.Context, key string, values ...string) (int64, error)
- func (c *ValkeyCache) LRange(ctx context.Context, key string, start, stop int64) ([]string, error)
- func (c *ValkeyCache) RPop(ctx context.Context, key string) (string, error)
- func (c *ValkeyCache) RPush(ctx context.Context, key string, values ...string) (int64, error)
- func (c *ValkeyCache) Set(ctx context.Context, key, value string, opts ...SetOption) error
- func (c *ValkeyCache) Underlying() valkey.Client
- type ValkeyCacheAPI
Constants ¶
const ( ModeStandalone = "standalone" ModeCluster = "cluster" ModeAuto = "auto" )
Variables ¶
var ErrNotFound = errors.New("valkey: key not found")
ErrNotFound is returned when a key does not exist in Valkey.
Functions ¶
This section is empty.
Types ¶
type Client ¶ added in v0.1.12
type Client struct {
Connection goredis.UniversalClient
}
func CreateNewRedisClient ¶
func CreateNewRedisClient(config RedisConfig) *Client
func (*Client) ClusterNodes ¶ added in v0.1.12
func (*Client) DeleteHash ¶ added in v0.1.12
func (*Client) DeleteListElements ¶ added in v0.1.12
func (*Client) DeleteString ¶ added in v0.1.12
Works only with Redis >= 6.2.0, use `SetStringWithExpiry` with versions lower than 6.2
func (*Client) GetHashVals ¶ added in v0.1.12
func (c *Client) GetHashVals(key string) *goredis.StringSliceCmd
func (*Client) GetListRange ¶ added in v0.1.12
func (c *Client) GetListRange(key string, start, end int64) *goredis.StringSliceCmd
func (*Client) GetSetMembers ¶ added in v0.1.12
func (c *Client) GetSetMembers(key string) *goredis.StringSliceCmd
func (*Client) SetListContents ¶ added in v0.1.12
type Option ¶ added in v0.2.13
type Option func(*config)
Option configures ValkeyCache.
type RedisConfig ¶ added in v0.1.12
type RedisConfig struct {
Enabled bool
Url string
Username string
Password string
OperationMode string
MaxActiveConnections int
MaxIdleConnections int
IdleTimeoutInSeconds int
CrashAppOnConnectionFailure bool
ConnectRetryIntervalInSeconds int
AutoExpireTopLevelKeysAfterSeconds int
AppNamespace string
}
type SetOption ¶ added in v0.2.13
type SetOption func(*setOptions)
SetOption configures the Set operation (e.g., expiration).
func WithExpiration ¶ added in v0.2.13
WithExpiration sets the expiration for the key.
type ValkeyCache ¶ added in v0.2.13
type ValkeyCache struct {
// contains filtered or unexported fields
}
ValkeyCache is an idiomatic Go wrapper around valkey-go for standalone Valkey servers.
func NewValkeyCache ¶ added in v0.2.13
func NewValkeyCache(host, port string, opts ...Option) (*ValkeyCache, error)
NewValkeyCache creates a new ValkeyCache instance connected to the given host and port. Supports optional configuration via functional options (e.g., WithAuth, WithTLS).
func (*ValkeyCache) Close ¶ added in v0.2.13
func (c *ValkeyCache) Close()
Close closes the underlying Valkey client and releases resources.
func (*ValkeyCache) Get ¶ added in v0.2.13
Get retrieves the string value for a key. Returns ErrNotFound if the key does not exist.
func (*ValkeyCache) LPop ¶ added in v0.2.13
LPop pops a value from the head of the list at key. Returns ErrNotFound if the list is empty or the key does not exist.
func (*ValkeyCache) LPush ¶ added in v0.2.13
LPush pushes values to the head of the list at key. Returns the new length of the list.
func (*ValkeyCache) LRange ¶ added in v0.2.13
LRange returns the elements of the list at key between start and stop (inclusive). Returns an empty slice if the key does not exist.
func (*ValkeyCache) RPop ¶ added in v0.2.13
RPop pops a value from the tail of the list at key. Returns ErrNotFound if the list is empty or the key does not exist.
func (*ValkeyCache) RPush ¶ added in v0.2.13
RPush pushes values to the tail of the list at key. Returns the new length of the list.
func (*ValkeyCache) Set ¶ added in v0.2.13
Set sets the string value for a key, optionally with expiration.
func (*ValkeyCache) Underlying ¶ added in v0.2.13
func (c *ValkeyCache) Underlying() valkey.Client
Underlying returns the underlying valkey.Client for advanced use.
type ValkeyCacheAPI ¶ added in v0.2.13
type ValkeyCacheAPI interface {
Set(ctx context.Context, key, value string, opts ...SetOption) error
Get(ctx context.Context, key string) (string, error)
LPush(ctx context.Context, key string, values ...string) (int64, error)
RPush(ctx context.Context, key string, values ...string) (int64, error)
LPop(ctx context.Context, key string) (string, error)
RPop(ctx context.Context, key string) (string, error)
LRange(ctx context.Context, key string, start, stop int64) ([]string, error)
Close()
// Underlying returns the underlying valkey.Client for advanced use.
Underlying() valkey.Client
}
ValkeyCacheAPI defines the interface for the cache wrapper. Useful for dependency injection and testing.