kvs

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

func New

func New(addr string, opts ...Options) (*Cache, error)

func (*Cache) Client

func (c *Cache) Client() *redis.Client

func (*Cache) Close

func (c *Cache) Close() error

func (*Cache) Delete

func (c *Cache) Delete(ctx context.Context, key string) error

Delete key

func (*Cache) Get

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

Get string value

func (*Cache) GetBytes

func (c *Cache) GetBytes(ctx context.Context, key string) ([]byte, error)

func (*Cache) GetInt64

func (c *Cache) GetInt64(ctx context.Context, key string) (int64, error)

GetInt64 return int64 value of key

func (*Cache) GetJSON

func (c *Cache) GetJSON(ctx context.Context, key string, v interface{}) error

GetJSON unmarshal json into v

func (*Cache) GetJSONWithTTL added in v1.12.0

func (c *Cache) GetJSONWithTTL(ctx context.Context, key string, v interface{}) (cache.LookupMeta, error)

func (*Cache) GetWithTTL added in v1.12.0

func (c *Cache) GetWithTTL(ctx context.Context, key string) (string, cache.LookupMeta, error)

func (*Cache) HDel added in v1.5.0

func (c *Cache) HDel(ctx context.Context, key, field string) error

func (*Cache) HGet added in v1.5.0

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

func (*Cache) HGetAll added in v1.5.0

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

func (*Cache) HGetAllMulti added in v1.10.0

func (c *Cache) HGetAllMulti(ctx context.Context, keys []string) ([]map[string]string, error)

HGetAllMulti pipelines len(keys) HGETALL commands in a single round-trip.

func (*Cache) HIncrBy added in v1.10.0

func (c *Cache) HIncrBy(ctx context.Context, key, field string, delta int64) (int64, error)

func (*Cache) HSet added in v1.5.0

func (c *Cache) HSet(ctx context.Context, key, field, value string) error

func (*Cache) Incr

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

Incr increment numerical value

func (*Cache) MGetBytes added in v1.10.0

func (c *Cache) MGetBytes(ctx context.Context, keys ...string) ([][]byte, error)

MGetBytes fetches multiple keys in a single MGET round-trip.

func (*Cache) Ping added in v1.12.0

func (c *Cache) Ping(ctx context.Context) error

func (*Cache) ReleaseRefreshLock added in v1.12.0

func (c *Cache) ReleaseRefreshLock(ctx context.Context, key, token string) error

func (*Cache) Set

func (c *Cache) Set(ctx context.Context, key, val string) error

Set string value

func (*Cache) SetInt64

func (c *Cache) SetInt64(ctx context.Context, key string, val int64) error

SetInt64 set int64 value

func (*Cache) SetJSON

func (c *Cache) SetJSON(ctx context.Context, key string, val interface{}) error

SetJSON marshal set marshaled json of val

func (*Cache) SetTTL

func (c *Cache) SetTTL(ctx context.Context, key string, ttl int64) error

SetTTL set expiration time for key

func (*Cache) SetTimed

func (c *Cache) SetTimed(ctx context.Context, key, val string, ttl int64) error

SetTimed set string value with expiration time in seconds

func (*Cache) SetTimedInt64

func (c *Cache) SetTimedInt64(ctx context.Context, key string, val int64, ttl int64) error

SetTimedInt64 set int64 value with expiration time in seconds

func (*Cache) SetTimedJSON

func (c *Cache) SetTimedJSON(ctx context.Context, key string, val interface{}, ttl int64, opts ...cache.TimedOption) error

func (*Cache) SetTimedJSONBatch added in v1.10.0

func (c *Cache) SetTimedJSONBatch(ctx context.Context, keys []string, vals []interface{}, ttl int64, opts ...cache.TimedOption) error

SetTimedJSONBatch pipelines N SETEX commands in a single round-trip.

func (*Cache) SetTimedJSONNX added in v1.7.0

func (c *Cache) SetTimedJSONNX(ctx context.Context, key string, val interface{}, ttl int64, opts ...cache.TimedOption) (bool, error)

func (*Cache) TryAcquireRefreshLock added in v1.12.0

func (c *Cache) TryAcquireRefreshLock(ctx context.Context, key, token string, ttl time.Duration) (bool, error)

func (*Cache) XAdd added in v1.5.0

func (c *Cache) XAdd(ctx context.Context, stream string, maxLen int64, approx bool, values map[string]interface{}) error

func (*Cache) ZAdd added in v1.10.0

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

func (*Cache) ZAddBatch added in v1.10.0

func (c *Cache) ZAddBatch(ctx context.Context, key string, members []cache.ZBatchMember) error

ZAddBatch adds multiple members to a sorted set in one ZADD command.

func (*Cache) ZRem added in v1.10.0

func (c *Cache) ZRem(ctx context.Context, key string, members ...string) error

func (*Cache) ZRevRangeByScore added in v1.10.0

func (c *Cache) ZRevRangeByScore(ctx context.Context, key, max, min string, offset, count int64) ([]string, error)

type Options added in v1.11.0

type Options struct {
	PoolSize     int           // default 256
	MinIdleConns int           // default 32
	DialTimeout  time.Duration // default 200ms
	ReadTimeout  time.Duration // default 200ms
	WriteTimeout time.Duration // default 200ms
}

Options configures the Redis connection pool. Zero values use defaults.

Jump to

Keyboard shortcuts

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