redis

package
v0.0.28 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 1, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

Types

type CircuitBreakerConfig

type CircuitBreakerConfig struct {
	Enabled     bool
	MaxRequests uint32
	Interval    time.Duration
	Timeout     time.Duration
}

type Cluster

type Cluster struct {
	Client      *redis.ClusterClient
	IsAvailable atomic.Bool
	// contains filtered or unexported fields
}

func InitRedisCluster

func InitRedisCluster(ctx context.Context, cfg Config) (*Cluster, error)

func (*Cluster) Del

func (c *Cluster) Del(ctx context.Context, keys ...string) (int64, error)

Del deletes one or more keys

func (*Cluster) Exists

func (c *Cluster) Exists(ctx context.Context, keys ...string) (int64, error)

Exists checks if one or more keys exist

func (*Cluster) Expire

func (c *Cluster) Expire(ctx context.Context, key string, ttl time.Duration) (bool, error)

Expire sets a time-to-live (TTL) for a key

func (*Cluster) Get

func (c *Cluster) Get(ctx context.Context, key string) (string, error)

Get retrieves the value of a key

func (*Cluster) GetDel

func (c *Cluster) GetDel(ctx context.Context, key string) (string, error)

GetDel gets the value of a key and deletes it

func (*Cluster) HDel

func (c *Cluster) HDel(ctx context.Context, key string, fields ...string) (int64, error)

HDel deletes one or more fields from a hash

func (*Cluster) HGet

func (c *Cluster) HGet(ctx context.Context, key, field string) (string, error)

HGet gets the value of a field in a hash

func (*Cluster) HSet

func (c *Cluster) HSet(ctx context.Context, key string, values ...interface{}) error

HSet sets one or more fields in a hash

func (*Cluster) Incr

func (c *Cluster) Incr(ctx context.Context, key string) (int64, error)

Incr increments the integer value of a key by one

func (*Cluster) IsAlive

func (c *Cluster) IsAlive() bool

func (*Cluster) Keys added in v0.0.27

func (c *Cluster) Keys(ctx context.Context, pattern string) ([]string, error)

Keys returns all keys matching the pattern (use with caution in production)

func (*Cluster) Persist added in v0.0.21

func (c *Cluster) Persist(ctx context.Context, key string) (bool, error)

Persist removes the TTL from a key, making it persistent

func (*Cluster) PingAll

func (c *Cluster) PingAll(ctx context.Context) bool

func (*Cluster) Rename added in v0.0.27

func (c *Cluster) Rename(ctx context.Context, oldKey, newKey string) error

Rename renames a key

func (*Cluster) RenameNX added in v0.0.27

func (c *Cluster) RenameNX(ctx context.Context, oldKey, newKey string) (bool, error)

RenameNX renames a key only if the new key does not exist

func (*Cluster) SAdd added in v0.0.21

func (c *Cluster) SAdd(ctx context.Context, key string, members ...interface{}) (int64, error)

SAdd adds one or more members to a set

func (*Cluster) SCard added in v0.0.28

func (c *Cluster) SCard(ctx context.Context, key string) (int64, error)

SCard returns the number of elements in a set

func (*Cluster) SIsMember added in v0.0.25

func (c *Cluster) SIsMember(ctx context.Context, key string, member interface{}) (bool, error)

SIsMember checks if a member exists in a set

func (*Cluster) SMIsMember added in v0.0.26

func (c *Cluster) SMIsMember(ctx context.Context, key string, members ...interface{}) ([]bool, error)

SMIsMember checks if multiple members exist in a set. Returns a slice of booleans

func (*Cluster) SMembers added in v0.0.24

func (c *Cluster) SMembers(ctx context.Context, key string) ([]string, error)

SMembers retrieves all members of a set

func (*Cluster) SRem added in v0.0.27

func (c *Cluster) SRem(ctx context.Context, key string, members ...interface{}) (int64, error)

SRem removes one or more members from a set

func (*Cluster) Set

func (c *Cluster) Set(ctx context.Context, key string, value interface{}, expiration time.Duration) error

Set sets a key with a given value and expiration

func (*Cluster) TTL

func (c *Cluster) TTL(ctx context.Context, key string) (time.Duration, error)

TTL gets the remaining time-to-live for a key

func (*Cluster) Touch added in v0.0.21

func (c *Cluster) Touch(ctx context.Context, key string, ttl time.Duration) error

Touch updates the TTL of a key if it exists

type ClusterConfig added in v0.0.18

type ClusterConfig struct {
	Enabled bool
	Nodes   []string
}

type Config

type Config struct {
	Cluster        ClusterConfig
	Retry          RetryConfig
	CircuitBreaker CircuitBreakerConfig
	Password       string
	DialTimeout    time.Duration
	ReadTimeout    time.Duration
	WriteTimeout   time.Duration
	MaxRetries     int
	PoolSize       int
	TTL            time.Duration
	DefaultTTL     time.Duration
}

type RetryConfig

type RetryConfig struct {
	MaxTries   int
	Backoff    time.Duration
	MaxBackoff time.Duration
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL