redis

package
v0.0.22 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClusterRedis

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

ClusterRedis 表示 Redis 集群缓存客户端。

func NewClusterRedis

func NewClusterRedis(cfg *configv1.Data_Redis) (*ClusterRedis, func(), error)

NewClusterRedis 创建 Redis 集群缓存实例。

func (*ClusterRedis) Connect

func (s *ClusterRedis) Connect() error

func (*ClusterRedis) Del

func (s *ClusterRedis) Del(key string) error

func (*ClusterRedis) DisConnect

func (s *ClusterRedis) DisConnect() error

func (*ClusterRedis) Exists

func (s *ClusterRedis) Exists(key string) bool

func (*ClusterRedis) Expire

func (s *ClusterRedis) Expire(key string, dur time.Duration) error

func (*ClusterRedis) Get

func (s *ClusterRedis) Get(key string) (string, error)

func (*ClusterRedis) GetDel added in v0.0.16

func (s *ClusterRedis) GetDel(key string) (string, error)

GetDel 使用 Redis GETDEL 原子读取并删除缓存值。

func (*ClusterRedis) HDel

func (s *ClusterRedis) HDel(key, field string) error

func (*ClusterRedis) HExists

func (s *ClusterRedis) HExists(key, field string) error

func (*ClusterRedis) HGet

func (s *ClusterRedis) HGet(key, field string) (string, error)

func (*ClusterRedis) HGetAll

func (s *ClusterRedis) HGetAll(key string) (map[string]string, error)

func (*ClusterRedis) HSet

func (s *ClusterRedis) HSet(key, field, value string) error

func (*ClusterRedis) Incr added in v0.0.19

func (s *ClusterRedis) Incr(key string) (int64, error)

Incr 原子递增 Redis 集群中的数值键。

func (*ClusterRedis) List added in v0.0.20

func (s *ClusterRedis) List() ([]store.Entry, error)

List 返回 Redis 集群中支持的缓存条目及其运行时元数据。

func (*ClusterRedis) Set

func (s *ClusterRedis) Set(key, value string, expire time.Duration) error

type Redis

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

func NewRedis

func NewRedis(cfg *configv1.Data_Redis) (*Redis, func(), error)

NewRedis 创建单机 Redis 缓存实例。

func (*Redis) Del

func (s *Redis) Del(key string) error

func (*Redis) Exists

func (s *Redis) Exists(key string) bool

func (*Redis) Expire

func (s *Redis) Expire(key string, dur time.Duration) error

func (*Redis) Get

func (s *Redis) Get(key string) (string, error)

func (*Redis) GetDel added in v0.0.16

func (s *Redis) GetDel(key string) (string, error)

GetDel 使用 Redis GETDEL 原子读取并删除缓存值。

func (*Redis) HDel

func (s *Redis) HDel(key, field string) error

func (*Redis) HExists

func (s *Redis) HExists(key, field string) error

func (*Redis) HGet

func (s *Redis) HGet(key, field string) (string, error)

func (*Redis) HGetAll

func (s *Redis) HGetAll(key string) (map[string]string, error)

func (*Redis) HSet

func (s *Redis) HSet(key, field, value string) error

func (*Redis) Incr added in v0.0.19

func (s *Redis) Incr(key string) (int64, error)

Incr 原子递增 Redis 中的数值键。

func (*Redis) List added in v0.0.20

func (s *Redis) List() ([]store.Entry, error)

List 返回 Redis 中支持的缓存条目及其运行时元数据。

func (*Redis) Set

func (s *Redis) Set(key, value string, expire time.Duration) error

type Store added in v0.0.16

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

Store 是支持 context、GetDel、SetNX 和批量操作的 Redis 缓存。

func NewStore added in v0.0.16

func NewStore(client redis.UniversalClient, opts ...StoreOption) *Store

NewStore 创建基于 Redis UniversalClient 的现代缓存实现。 Store 不接管 client 生命周期,Close 不会关闭底层 Redis 客户端。

func (*Store) Close added in v0.0.16

func (s *Store) Close() error

Close 保留底层 Redis 客户端的调用方所有权。

func (*Store) Delete added in v0.0.16

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

Delete 删除缓存值。

func (*Store) Get added in v0.0.16

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

Get 获取缓存值。

func (*Store) GetDel added in v0.0.16

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

GetDel 使用 Redis GETDEL 原子读取并删除缓存值。

func (*Store) GetMulti added in v0.0.16

func (s *Store) GetMulti(ctx context.Context, keys []string) ([][]byte, error)

GetMulti 使用 MGET 按输入顺序批量获取缓存值。

func (*Store) Has added in v0.0.16

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

Has 判断缓存键是否存在。

func (*Store) Set added in v0.0.16

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

Set 写入缓存值。

func (*Store) SetMulti added in v0.0.16

func (s *Store) SetMulti(ctx context.Context, items []store.Item) error

SetMulti 使用 Pipeline 批量写入缓存值。

func (*Store) SetNX added in v0.0.16

func (s *Store) SetNX(ctx context.Context, key string, value []byte, ttl time.Duration) (bool, error)

SetNX 使用 Redis SET NX 原子写入不存在的键。

type StoreOption added in v0.0.16

type StoreOption func(*storeConfig)

StoreOption 配置 Redis Store。

func WithStoreKeyPrefix added in v0.0.16

func WithStoreKeyPrefix(prefix string) StoreOption

WithStoreKeyPrefix 设置 Redis Store 的缓存键前缀。

Jump to

Keyboard shortcuts

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