Documentation
¶
Index ¶
- Variables
- func Decr(ctx context.Context, key string, expire time.Duration) (int64, error)
- func DecrByClient(ctx context.Context, cli redis.UniversalClient, key string, ...) (int64, error)
- func Del(ctx context.Context, key string) error
- func DelByClient(ctx context.Context, cli redis.UniversalClient, key string) error
- func Get[T any](ctx context.Context, key string) (T, error)
- func GetByClient[T any](ctx context.Context, cli redis.UniversalClient, key string) (T, error)
- func Incr(ctx context.Context, key string, expire time.Duration) (int64, error)
- func IncrByClient(ctx context.Context, cli redis.UniversalClient, key string, ...) (int64, error)
- func Set[T any](ctx context.Context, key string, value T, expire time.Duration) error
- func SetByClient[T any](ctx context.Context, cli redis.UniversalClient, key string, value T, ...) error
- func SetClient(cli redis.UniversalClient)
- type Element
- type ElementList
- type HashMap
- func (h *HashMap[K, V]) Delete(ctx context.Context, fields ...K) error
- func (h *HashMap[K, V]) Exists(ctx context.Context, field K) (bool, error)
- func (h *HashMap[K, V]) Get(ctx context.Context, field K) (V, error)
- func (h *HashMap[K, V]) GetAll(ctx context.Context) (map[K]V, error)
- func (h *HashMap[K, V]) GetMulti(ctx context.Context, fields []K) (map[K]V, error)
- func (h *HashMap[K, V]) Incr(ctx context.Context, field K, increment int64, expire time.Duration) (int64, error)
- func (h *HashMap[K, V]) IncrFloat(ctx context.Context, field K, increment float64, expire time.Duration) (float64, error)
- func (h *HashMap[K, V]) Keys(ctx context.Context) ([]K, error)
- func (h *HashMap[K, V]) Len(ctx context.Context) (int64, error)
- func (h *HashMap[K, V]) Set(ctx context.Context, field K, value V, expire time.Duration) error
- func (h *HashMap[K, V]) SetMulti(ctx context.Context, fields map[K]V, expire time.Duration) error
- func (h *HashMap[K, V]) Values(ctx context.Context) ([]V, error)
- type ZQueue
- func (q *ZQueue[T]) Add(ctx context.Context, member T, score int64, expire time.Duration) error
- func (q *ZQueue[T]) AddMulti(ctx context.Context, elements []Element[T], expire time.Duration) error
- func (q *ZQueue[T]) Count(ctx context.Context) (int64, error)
- func (q *ZQueue[T]) CountByScore(ctx context.Context, min, max string) (int64, error)
- func (q *ZQueue[T]) PopMax(ctx context.Context) (*Element[T], error)
- func (q *ZQueue[T]) PopMaxMulti(ctx context.Context, count int64) ([]Element[T], error)
- func (q *ZQueue[T]) PopMin(ctx context.Context) (*Element[T], error)
- func (q *ZQueue[T]) PopMinMulti(ctx context.Context, count int64) ([]Element[T], error)
- func (q *ZQueue[T]) RangeByScore(ctx context.Context, minScore, maxScore int64) ([]Element[T], error)
- func (q *ZQueue[T]) RangeByScoreRev(ctx context.Context, minScore, maxScore int64) ([]Element[T], error)
- func (q *ZQueue[T]) RangeByScoreWithLimit(ctx context.Context, minScore, maxScore int64, offset, count int64) ([]Element[T], error)
- func (q *ZQueue[T]) RangeByScoreWithLimitRev(ctx context.Context, minScore, maxScore int64, offset, count int64) ([]Element[T], error)
- func (q *ZQueue[T]) RangeFromScore(ctx context.Context, minScore int64) ([]Element[T], error)
- func (q *ZQueue[T]) RangeFromScoreRev(ctx context.Context, minScore int64) ([]Element[T], error)
- func (q *ZQueue[T]) RangeToScore(ctx context.Context, maxScore int64) ([]Element[T], error)
- func (q *ZQueue[T]) RangeToScoreRev(ctx context.Context, maxScore int64) ([]Element[T], error)
- func (q *ZQueue[T]) Remove(ctx context.Context, member T) error
- func (q *ZQueue[T]) RemoveMulti(ctx context.Context, members []T) error
- func (q *ZQueue[T]) RemoveRangeByScore(ctx context.Context, min, max string) (int64, error)
- func (q *ZQueue[T]) Score(ctx context.Context, member T) (int64, error)
Constants ¶
This section is empty.
Variables ¶
var GlobalClient redis.UniversalClient
Functions ¶
func DecrByClient ¶
func DelByClient ¶
func GetByClient ¶
func IncrByClient ¶
func SetByClient ¶
func SetClient ¶
func SetClient(cli redis.UniversalClient)
Types ¶
type ElementList ¶
func (ElementList[T]) Members ¶
func (e ElementList[T]) Members() []T
type HashMap ¶
type HashMap[K comparable, V any] struct { Key string Cli redis.UniversalClient }
func NewHashMap ¶
func NewHashMap[K comparable, V any](cli redis.UniversalClient, key string) *HashMap[K, V]
func (*HashMap[K, V]) Incr ¶
func (h *HashMap[K, V]) Incr(ctx context.Context, field K, increment int64, expire time.Duration) (int64, error)
Incr increments the integer value of a field by the given amount
func (*HashMap[K, V]) IncrFloat ¶
func (h *HashMap[K, V]) IncrFloat(ctx context.Context, field K, increment float64, expire time.Duration) (float64, error)
IncrFloat increments the float value of a field by the given amount
type ZQueue ¶
type ZQueue[T any] struct { Key string Cli redis.UniversalClient Desc bool // true for descending order, false for ascending order }
func (*ZQueue[T]) AddMulti ¶
func (q *ZQueue[T]) AddMulti(ctx context.Context, elements []Element[T], expire time.Duration) error
AddMulti adds multiple elements to the sorted set
func (*ZQueue[T]) CountByScore ¶
CountByScore returns the number of elements with scores between min and max Use "-inf" for min or "+inf" for max to represent infinity
func (*ZQueue[T]) PopMaxMulti ¶
PopMaxMulti removes and returns multiple elements with the highest scores
func (*ZQueue[T]) PopMinMulti ¶
PopMinMulti removes and returns multiple elements with the lowest scores
func (*ZQueue[T]) RangeByScore ¶
func (q *ZQueue[T]) RangeByScore(ctx context.Context, minScore, maxScore int64) ([]Element[T], error)
RangeByScore returns elements with scores between min and max Respects the Desc field in ZQueue
func (*ZQueue[T]) RangeByScoreRev ¶
func (q *ZQueue[T]) RangeByScoreRev(ctx context.Context, minScore, maxScore int64) ([]Element[T], error)
RangeByScoreRev returns elements with scores between min and max in reversed order Reverses the Desc field in ZQueue
func (*ZQueue[T]) RangeByScoreWithLimit ¶
func (q *ZQueue[T]) RangeByScoreWithLimit(ctx context.Context, minScore, maxScore int64, offset, count int64) ([]Element[T], error)
RangeByScoreWithLimit returns elements with scores between min and max with pagination Respects the Desc field in ZQueue
func (*ZQueue[T]) RangeByScoreWithLimitRev ¶
func (q *ZQueue[T]) RangeByScoreWithLimitRev(ctx context.Context, minScore, maxScore int64, offset, count int64) ([]Element[T], error)
RangeByScoreWithLimitRev returns elements with scores between min and max with pagination in reversed order Reverses the Desc field in ZQueue
func (*ZQueue[T]) RangeFromScore ¶
RangeFromScore returns elements with scores >= minScore Respects the Desc field in ZQueue
func (*ZQueue[T]) RangeFromScoreRev ¶
RangeFromScoreRev returns elements with scores >= minScore in reversed order Reverses the Desc field in ZQueue
func (*ZQueue[T]) RangeToScore ¶
RangeToScore returns elements with scores <= maxScore Respects the Desc field in ZQueue
func (*ZQueue[T]) RangeToScoreRev ¶
RangeToScoreRev returns elements with scores <= maxScore in reversed order Reverses the Desc field in ZQueue
func (*ZQueue[T]) RemoveMulti ¶
RemoveMulti removes multiple elements from the sorted set
func (*ZQueue[T]) RemoveRangeByScore ¶
RemoveRangeByScore removes elements with scores between min and max Use "-inf" for min or "+inf" for max to represent infinity