redis

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package redis provides a Redis-backed implementation of store.Store.

It wraps redis.UniversalClient, which supports Redis standalone, Redis Cluster, and Redis Sentinel out of the box.

client := redis.NewClient(&redis.Options{Addr: "localhost:6379"})
s := redisstore.New(client)

// Or with Redis Cluster:
client := redis.NewClusterClient(&redis.ClusterOptions{
    Addrs: []string{"node1:6379", "node2:6379", "node3:6379"},
})
s := redisstore.New(client)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store implements store.Store backed by Redis.

func New

func New(client goredis.UniversalClient) *Store

New creates a Redis-backed Store from any UniversalClient (standalone *redis.Client, *redis.ClusterClient, or *redis.Ring).

func (*Store) Client

func (s *Store) Client() goredis.UniversalClient

Client returns the underlying Redis client.

func (*Store) Close

func (s *Store) Close() error

func (*Store) Del

func (s *Store) Del(ctx context.Context, keys ...string) error

func (*Store) Eval

func (s *Store) Eval(ctx context.Context, script string, keys []string, args ...interface{}) (interface{}, error)

func (*Store) EvalSha

func (s *Store) EvalSha(ctx context.Context, sha1 string, keys []string, args ...interface{}) (interface{}, error)

func (*Store) Expire

func (s *Store) Expire(ctx context.Context, key string, ttl time.Duration) error

func (*Store) Get

func (s *Store) Get(ctx context.Context, key string) (string, error)

func (*Store) HGetAll

func (s *Store) HGetAll(ctx context.Context, key string) (map[string]string, error)

func (*Store) HSet

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

func (*Store) IncrBy

func (s *Store) IncrBy(ctx context.Context, key string, n int64) (int64, error)

func (*Store) Pipeline

func (s *Store) Pipeline() store.Pipeline

func (*Store) ScriptLoad

func (s *Store) ScriptLoad(ctx context.Context, script string) (string, error)

func (*Store) Set

func (s *Store) Set(ctx context.Context, key string, value string, ttl time.Duration) error

func (*Store) TTL

func (s *Store) TTL(ctx context.Context, key string) (time.Duration, error)

func (*Store) ZAdd

func (s *Store) ZAdd(ctx context.Context, key string, score float64, member string) error

func (*Store) ZCard

func (s *Store) ZCard(ctx context.Context, key string) (int64, error)

func (*Store) ZRangeWithScores

func (s *Store) ZRangeWithScores(ctx context.Context, key string, start, stop int64) ([]store.ZEntry, error)

func (*Store) ZRemRangeByScore

func (s *Store) ZRemRangeByScore(ctx context.Context, key, min, max string) error

Jump to

Keyboard shortcuts

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