Documentation
¶
Index ¶
- Constants
- Variables
- func Float64ToInt64(f float64) (int64, error)
- func IdScoreToZ(is *IdScore) (redis.Z, bool, error)
- func Int64ToFloat64(i int64) (float64, error)
- func IsRedisNil(err error) bool
- func IsRedisNoGroup(err error) bool
- func MapKV[K comparable, V any, T KeyValuer[K, V]](values []T) map[K]V
- func NewTimeZ(id int64, ts time.Time) redis.Z
- func NewZ(member string, score int64) redis.Z
- func RedisDecode(typ reflect.Type, strVal string) (any, error)
- func RedisEncode(value any) (string, error)
- func RedisInt64Decoder(s string) (int64, error)
- func RedisInt64Encoder(s int64) (string, error)
- func RedisInt64SliceDecoder(s string) ([]int64, error)
- func RedisInt64SliceEncoder(s []int64) (string, error)
- func RedisStringDecoder(s string) (string, error)
- func RedisStringEncoder(s string) (string, error)
- func RedisStringSliceDecoder(s string) ([]string, error)
- func RedisStringSliceEncoder(s []string) (string, error)
- func RedisUint64Decoder(s string) (uint64, error)
- func RedisUint64Encoder(s uint64) (string, error)
- func RedisValueDecode[T any](val any, decoder func(string) (T, error)) (exist bool, t T, err error)
- func TypeDecoder[T any](typ reflect.Type, strVal string) (t T, err error)
- func TypeEncoder[T any](value T) (string, error)
- type BatchIterator
- type IdScore
- type IsNil
- type KeyValuer
- type MapLoader
- type RedisAtomicPointer
- type RedisBatchValue
- type RedisClient
- func (c *RedisClient) C() *redis.Client
- func (c *RedisClient) Del(ctx context.Context, keys ...string) error
- func (c *RedisClient) Exist(ctx context.Context, key string) bool
- func (c *RedisClient) Get(ctx context.Context, key string, typ reflect.Type) (any, bool, error)
- func (c *RedisClient) GetIds(ctx context.Context, key string) ([]int64, bool, error)
- func (c *RedisClient) GetStringWithNil(ctx context.Context, key string) (string, error)
- func (c *RedisClient) GetValues(ctx context.Context, typ reflect.Type, keys ...string) (hitList []bool, values any, errr error)
- func (c *RedisClient) HDel(ctx context.Context, key string, fields ...string) error
- func (c *RedisClient) HDels(ctx context.Context, key string, fields ...string) error
- func (c *RedisClient) HGet(ctx context.Context, key, field string, typ reflect.Type) (any, bool, error)
- func (c *RedisClient) HGets(ctx context.Context, key string, typ reflect.Type, fields ...string) (hitList []bool, cached any, err error)
- func (c *RedisClient) HGetsAll(ctx context.Context, key string, typ reflect.Type) (any, error)
- func (c *RedisClient) HSet(ctx context.Context, key, field string, value any) error
- func (c *RedisClient) HSetMap(ctx context.Context, key string, m map[string]any) error
- func (c *RedisClient) HSets(ctx context.Context, key string, fieldValues ...any) error
- func (c *RedisClient) HSetsOnce(ctx context.Context, key string, fieldValues ...any) error
- func (c *RedisClient) InitStreamGroup(ctx context.Context, streamName string, groupName string) error
- func (c *RedisClient) QueueAck(ctx context.Context, stream, group string, ids ...string) error
- func (c *RedisClient) QueuePush(ctx context.Context, stream string, minId string, ...) error
- func (c *RedisClient) QueuePushMaxLen(ctx context.Context, stream string, maxLen int64, values ...map[string]any) error
- func (c *RedisClient) QueueRead(ctx context.Context, stream string, timeout time.Duration, count int64, ...) ([]redis.XMessage, error)
- func (c *RedisClient) QueueReadGroup(ctx context.Context, stream, group, worker string, timeout time.Duration, ...) ([]redis.XMessage, error)
- func (c *RedisClient) ResetZSet(ctx context.Context, key string, zs ...redis.Z) error
- func (c *RedisClient) Set(ctx context.Context, key string, value any, expire ...time.Duration) error
- func (c *RedisClient) SetValues(ctx context.Context, pairs ...any) error
- func (c *RedisClient) SetZSet(ctx context.Context, key string, zs ...redis.Z) error
- func (c *RedisClient) String() string
- func (c *RedisClient) Version() common.Version
- func (c *RedisClient) ZScoreByPaddedIds(ctx context.Context, key string, paddedIds ...string) (map[int64]int64, error)
- type RedisDecoder
- type RedisEncoder
- type RedisFloatDecoder
- type RedisFloatEncoder
- type RedisHasher
- func NewHashReader[K comparable, V any](client redis.Cmdable, fieldEncoder RedisEncoder[K], ...) *RedisHasher[K, V]
- func NewRedisHasher[K comparable, V any](client redis.Cmdable, fieldEncoder RedisEncoder[K], ...) *RedisHasher[K, V]
- func NewStringInt64Hasher(c redis.Cmdable) *RedisHasher[string, int64]
- func (t *RedisHasher[K, V]) FieldDecoder(decoder RedisDecoder[K]) *RedisHasher[K, V]
- func (t *RedisHasher[K, V]) FieldEncoder(encoder RedisEncoder[K]) *RedisHasher[K, V]
- func (t *RedisHasher[K, V]) HDel(ctx context.Context, key string, fields ...K) (int64, error)
- func (t *RedisHasher[K, V]) HDelFieldString(ctx context.Context, key string, fieldStrings ...string) (int64, error)
- func (t *RedisHasher[K, V]) HExists(ctx context.Context, key string, field K) (bool, error)
- func (t *RedisHasher[K, V]) HExpire(ctx context.Context, key string, seconds int64, fields ...K) ([]bool, error)
- func (t *RedisHasher[K, V]) HGet(ctx context.Context, key string, field K) (hit bool, value V, err error)
- func (t *RedisHasher[K, V]) HGetAll(ctx context.Context, key string) (map[K]V, error)
- func (t *RedisHasher[K, V]) HGetAllAndSetIfNA(ctx context.Context, key string, ...) (map[K]V, error)
- func (t *RedisHasher[K, V]) HGetAndSet(ctx context.Context, key string, ...) (v V, err error)
- func (t *RedisHasher[K, V]) HGetAndSetIfNA(ctx context.Context, key string, ...) (v V, err error)
- func (t *RedisHasher[K, V]) HGetByFieldString(ctx context.Context, key string, fieldString string) (hit bool, value V, err error)
- func (t *RedisHasher[K, V]) HGetByFieldStrings(ctx context.Context, key string, fieldStrings ...string) (hitList []bool, cached map[K]V, err error)
- func (t *RedisHasher[K, V]) HGets(ctx context.Context, key string, fields ...K) (notcached []K, cached map[K]V, err error)
- func (t *RedisHasher[K, V]) HGetsAndSets(ctx context.Context, key string, ...) (map[K]V, error)
- func (t *RedisHasher[K, V]) HGetsAndSetsIfNA(ctx context.Context, key string, ...) (map[K]V, error)
- func (t *RedisHasher[K, V]) HKeys(ctx context.Context, key string) ([]K, error)
- func (t *RedisHasher[K, V]) HKeysAndSetIfNA(ctx context.Context, key string, ...) (fields []K, err error)
- func (t *RedisHasher[K, V]) HMustSets(ctx context.Context, key string, values []KeyValuer[K, V], mustFields []K, ...) error
- func (t *RedisHasher[K, V]) HMustSetsMap(ctx context.Context, key string, valueMap map[K]V, mustFields []K, ...) error
- func (t *RedisHasher[K, V]) HSet(ctx context.Context, key string, field K, value V) error
- func (t *RedisHasher[K, V]) HSets(ctx context.Context, key string, values []KeyValuer[K, V]) error
- func (t *RedisHasher[K, V]) HSetsMap(ctx context.Context, key string, valueMap map[K]V) error
- func (t *RedisHasher[K, V]) ValueDecoder(decoder RedisDecoder[V]) *RedisHasher[K, V]
- func (t *RedisHasher[K, V]) ValueEncoder(encoder RedisEncoder[V]) *RedisHasher[K, V]
- type RedisKey
- type RedisList
- type RedisLock
- func (l *RedisLock) Fetch(cctx context.Context) (lockingValue string, err error)
- func (l *RedisLock) FetchOrRefresh(cctx context.Context) (lockingValue string, err error)
- func (l *RedisLock) Refresh(cctx context.Context) (err error)
- func (l *RedisLock) Release() (err error)
- func (l *RedisLock) String() string
- type RedisMSZSet
- func (ms *RedisMSZSet[M, S]) WithBatchSize(batchSize int) *RedisMSZSet[M, S]
- func (ms *RedisMSZSet[M, S]) ZAdd(ctx context.Context, key string, msmap map[M]S) (int64, error)
- func (ms *RedisMSZSet[M, S]) ZCount(ctx context.Context, key string, min, max string) (count int64, err error)
- func (ms *RedisMSZSet[M, S]) ZIncrBy(ctx context.Context, key string, incrBy float64, m M) (s S, err error)
- func (ms *RedisMSZSet[M, S]) ZMScore(ctx context.Context, key string, inputs ...M) (map[M]S, error)
- func (ms *RedisMSZSet[M, S]) ZRangeArgs(ctx context.Context, args *ZArgs, placeHolder ...M) ([]M, error)
- func (ms *RedisMSZSet[M, S]) ZScore(ctx context.Context, key string, m M) (s S, err error)
- type RedisMsg
- func (m RedisMsg) ID(key string, nilIsOk ...bool) (tools.ID, error)
- func (m RedisMsg) Int64(key string, nilIsOk ...bool) (i int64, err error)
- func (m RedisMsg) IsEmpty() bool
- func (m RedisMsg) IsStopSignal() bool
- func (m RedisMsg) Map() map[string]interface{}
- func (m RedisMsg) StopSignal() RedisMsg
- func (m RedisMsg) String(key string, nilIsOk ...bool) (string, error)
- type RedisSet
- func (s *RedisSet[V]) SAdd(ctx context.Context, key string, vs ...V) (int64, error)
- func (s *RedisSet[V]) SAddWithEmpty(ctx context.Context, key string, emptyValue V, vs ...V) (int64, error)
- func (s *RedisSet[V]) SIsMember(ctx context.Context, key string, v V) (bool, error)
- func (s *RedisSet[V]) SRem(ctx context.Context, key string, vs ...V) (int64, error)
- func (s *RedisSet[V]) WithBatchSize(size int) *RedisSet[V]
- type RedisString
- func NewRedisString[K comparable, V any](client redis.Cmdable, keyEncoder RedisEncoder[K], valueEncoder RedisEncoder[V], ...) *RedisString[K, V]
- func NewStringReader[K comparable, V any](client redis.Cmdable, keyEncoder RedisEncoder[K], valueDecoder RedisDecoder[V]) *RedisString[K, V]
- func NewStringWriter[K comparable, V any](client redis.Cmdable, keyEncoder RedisEncoder[K], valueEncoder RedisEncoder[V]) *RedisString[K, V]
- func (s *RedisString[K, V]) Client(client redis.Cmdable) *RedisString[K, V]
- func (s *RedisString[K, V]) Get(ctx context.Context, k K) (exist bool, t V, err error)
- func (s *RedisString[K, V]) GetAndSet(ctx context.Context, ...) (v V, err error)
- func (s *RedisString[K, V]) Gets(ctx context.Context, ks ...K) (notcached []K, cached map[K]V, err error)
- func (s *RedisString[K, V]) GetsAndSets(ctx context.Context, dbLoader MapLoader[K, V], ks ...K) (map[K]V, error)
- func (s *RedisString[K, V]) KeyEncoder(encoder RedisEncoder[K]) *RedisString[K, V]
- func (s *RedisString[K, V]) Set(ctx context.Context, k K, v V, expire ...time.Duration) error
- func (s *RedisString[K, V]) Sets(ctx context.Context, values map[K]V) error
- func (s *RedisString[K, V]) ValueDecoder(decoder RedisDecoder[V]) *RedisString[K, V]
- func (s *RedisString[K, V]) ValueEncoder(encoder RedisEncoder[V]) *RedisString[K, V]
- type RedisZDecoder
- type RedisZEncoder
- type RedisZSet
- func (zs *RedisZSet[Z]) BZPopMin(ctx context.Context, timeout time.Duration, key string) ([]Z, error)
- func (zs *RedisZSet[Z]) WithBatchSize(size int) *RedisZSet[Z]
- func (zs *RedisZSet[Z]) ZAdd(ctx context.Context, key string, vs ...Z) (int64, error)
- func (zs *RedisZSet[Z]) ZAddCall(op func(client redis.Cmdable, vals ...redis.Z) (int64, error), vs ...Z) (int64, error)
- func (zs *RedisZSet[Z]) ZAddNX(ctx context.Context, key string, vs ...Z) (int64, error)
- func (zs *RedisZSet[Z]) ZAddNXWithEmpty(ctx context.Context, key string, emptyValue Z, vs ...Z) (int64, error)
- func (zs *RedisZSet[Z]) ZAddWithEmpty(ctx context.Context, key string, emptyValue Z, vs ...Z) (int64, error)
- func (zs *RedisZSet[Z]) ZCard(ctx context.Context, key string) (int64, error)
- func (zs *RedisZSet[Z]) ZCount(ctx context.Context, key string, min, max string) (int64, error)
- func (zs *RedisZSet[Z]) ZPopMin(ctx context.Context, key string, count ...int64) ([]Z, error)
- func (zs *RedisZSet[Z]) ZRangeWithScores(ctx context.Context, args *ZArgs) ([]Z, error)
- type Z
- type ZArgs
- func (a *ZArgs) ByIndex() *ZArgs
- func (a *ZArgs) ByLEX() *ZArgs
- func (a *ZArgs) ByScore() *ZArgs
- func (a *ZArgs) Fw() *ZArgs
- func (a *ZArgs) MaxString() string
- func (a *ZArgs) MinString() string
- func (a *ZArgs) Paginate(begin, size int64) *ZArgs
- func (a *ZArgs) Range(min, max any) *ZArgs
- func (a *ZArgs) Redis() redis.ZRangeArgs
- func (a *ZArgs) Rev() *ZArgs
- func (a *ZArgs) String() string
- func (a *ZArgs) WithKey(key string) *ZArgs
- type ZB
- type Zs
Constants ¶
const ( ModelsBatchSize = 100 BatchSize = 500 TypeKeyNone = "none" TypeKeyStream = "stream" RdbStatusOK = "OK" ErrBUSYGROUPKeyword = "BUSYGROUP" // DefaultStartScore zset default score range DefaultStartScore = "0" DefaultStopScore = "+inf" StringPlaceHolder = "_" IdPlaceHolder = 0 NegIdPlaceHolder = -1 // HashExpireMinVersion min version of redis-server starting support HExpire HashExpireMinVersion = common.Version(7004000) )
Variables ¶
var ( ErrInvalidValue = errors.New("rds: invalid value object") ErrExpectingString = errors.New("rds: expecting string") )
var EmptyZ = redis.Z{Score: -1, Member: "0"}
Functions ¶
func Float64ToInt64 ¶
func IdScoreToZ ¶
func Int64ToFloat64 ¶
func IsRedisNil ¶
func IsRedisNoGroup ¶
func MapKV ¶
func MapKV[K comparable, V any, T KeyValuer[K, V]](values []T) map[K]V
func RedisEncode ¶
func RedisInt64Decoder ¶
func RedisInt64Encoder ¶
func RedisInt64SliceDecoder ¶
func RedisInt64SliceEncoder ¶
func RedisStringDecoder ¶
func RedisStringEncoder ¶
func RedisStringSliceDecoder ¶
func RedisStringSliceEncoder ¶
func RedisUint64Decoder ¶
func RedisUint64Encoder ¶
func RedisValueDecode ¶
func TypeEncoder ¶
Types ¶
type BatchIterator ¶
type BatchIterator[T any] struct { // contains filtered or unexported fields }
func NewBatchIterator ¶
func NewBatchIterator[T any](ts []T, size ...int) *BatchIterator[T]
func (*BatchIterator[T]) Current ¶
func (b *BatchIterator[T]) Current() []T
func (*BatchIterator[T]) HasNext ¶
func (b *BatchIterator[T]) HasNext() bool
func (*BatchIterator[T]) Next ¶
func (b *BatchIterator[T]) Next() []T
func (*BatchIterator[T]) String ¶
func (b *BatchIterator[T]) String() string
type IdScore ¶
func ZToIdScore ¶
type KeyValuer ¶
type KeyValuer[K comparable, V any] interface { Key() K Value() V }
type MapLoader ¶
type MapLoader[K comparable, V any] func(ctx context.Context, ks ...K) (map[K]V, error)
type RedisAtomicPointer ¶
type RedisAtomicPointer[T any] struct { // contains filtered or unexported fields }
func NewAtomicPointer ¶
func NewAtomicPointer[T any](newT func(client *RedisClient, batchSize ...int) *T) *RedisAtomicPointer[T]
func (*RedisAtomicPointer[T]) Get ¶
func (a *RedisAtomicPointer[T]) Get(client *RedisClient, batchSize ...int) *T
type RedisBatchValue ¶
type RedisBatchValue[V any] struct { // contains filtered or unexported fields }
type RedisClient ¶
type RedisClient struct { *redis.Client // contains filtered or unexported fields }
func ConnectRedis ¶
func ConnectRedis(ctx context.Context, url string) (*RedisClient, error)
func (*RedisClient) C ¶
func (c *RedisClient) C() *redis.Client
func (*RedisClient) GetStringWithNil ¶
func (*RedisClient) GetValues ¶
func (c *RedisClient) GetValues(ctx context.Context, typ reflect.Type, keys ...string) (hitList []bool, values any, errr error)
GetValues returns hitList: same length as the input keys, indicates whether each key hit the cache values: array of decoded values or nil (not hit or cached nil)
func (*RedisClient) HGets ¶
func (c *RedisClient) HGets(ctx context.Context, key string, typ reflect.Type, fields ...string) (hitList []bool, cached any, err error)
HGets returns cached as map[string]anyOftyp
func (*RedisClient) InitStreamGroup ¶
func (c *RedisClient) InitStreamGroup(ctx context.Context, streamName string, groupName string) error
InitStreamGroup workers should call this at start procedure
func (*RedisClient) QueuePushMaxLen ¶
func (*RedisClient) QueueReadGroup ¶
func (*RedisClient) ResetZSet ¶
func (c *RedisClient) ResetZSet(ctx context.Context, key string, zs ...redis.Z) error
func (*RedisClient) SetValues ¶
func (c *RedisClient) SetValues(ctx context.Context, pairs ...any) error
func (*RedisClient) SetZSet ¶
func (c *RedisClient) SetZSet(ctx context.Context, key string, zs ...redis.Z) error
func (*RedisClient) String ¶
func (c *RedisClient) String() string
func (*RedisClient) Version ¶
func (c *RedisClient) Version() common.Version
func (*RedisClient) ZScoreByPaddedIds ¶
type RedisDecoder ¶
func NewTypeDecoder ¶
func NewTypeDecoder[T any](typ reflect.Type) RedisDecoder[T]
type RedisEncoder ¶
RedisEncoder returns "" means ignoring
type RedisFloatDecoder ¶
RedisFloatDecoder decoder for ZSet score
type RedisFloatEncoder ¶
RedisFloatEncoder encoder for ZSet score
type RedisHasher ¶
type RedisHasher[K comparable, V any] struct { // contains filtered or unexported fields }
func NewHashReader ¶
func NewHashReader[K comparable, V any](client redis.Cmdable, fieldEncoder RedisEncoder[K], fieldDecoder RedisDecoder[K], valueDecoder RedisDecoder[V]) *RedisHasher[K, V]
func NewRedisHasher ¶
func NewRedisHasher[K comparable, V any]( client redis.Cmdable, fieldEncoder RedisEncoder[K], fieldDecoder RedisDecoder[K], valueEncoder RedisEncoder[V], valueDecoder RedisDecoder[V]) *RedisHasher[K, V]
func NewStringInt64Hasher ¶
func NewStringInt64Hasher(c redis.Cmdable) *RedisHasher[string, int64]
func (*RedisHasher[K, V]) FieldDecoder ¶
func (t *RedisHasher[K, V]) FieldDecoder(decoder RedisDecoder[K]) *RedisHasher[K, V]
func (*RedisHasher[K, V]) FieldEncoder ¶
func (t *RedisHasher[K, V]) FieldEncoder(encoder RedisEncoder[K]) *RedisHasher[K, V]
func (*RedisHasher[K, V]) HDelFieldString ¶
func (*RedisHasher[K, V]) HGetAll ¶
func (t *RedisHasher[K, V]) HGetAll(ctx context.Context, key string) (map[K]V, error)
func (*RedisHasher[K, V]) HGetAllAndSetIfNA ¶
func (*RedisHasher[K, V]) HGetAndSet ¶
func (*RedisHasher[K, V]) HGetAndSetIfNA ¶
func (*RedisHasher[K, V]) HGetByFieldString ¶
func (*RedisHasher[K, V]) HGetByFieldStrings ¶
func (*RedisHasher[K, V]) HGets ¶
func (t *RedisHasher[K, V]) HGets(ctx context.Context, key string, fields ...K) (notcached []K, cached map[K]V, err error)
func (*RedisHasher[K, V]) HGetsAndSets ¶
func (t *RedisHasher[K, V]) HGetsAndSets(ctx context.Context, key string, dbLoader func(cctx context.Context, kks ...K) (map[K]V, error), ks ...K) (map[K]V, error)
HGetsAndSets read data from hashes:key using ks as the fields. If any fields do not exist, use dbLoader to read the corresponding data from the database and store it in the cache. Note that dbLoader should not return an error if the corresponding data does not exist in the database.
func (*RedisHasher[K, V]) HGetsAndSetsIfNA ¶
func (t *RedisHasher[K, V]) HGetsAndSetsIfNA(ctx context.Context, key string, allLoader func(ctx context.Context) (map[K]V, error), flagField K, kks ...K) (map[K]V, error)
HGetsAndSetsIfNA 检查key是否存在,如果不存在则通过allLoader获取所有key的数据并保存 redis的hash无法存储0个field,所以当使用hash存储对象时,如果不做特殊处理,将无法缓存不存在的key(如:数据库中不存在)。 此时通过使用在field中增加一个特殊值flag(不会与真实filed重复),用来保证没有其他field时也可以使得key在redis中。 而flag对应的值则是V的缺省值。 读取时,可以通过HMGet每次都将flag读取出来,一旦flag不存在,就说明key不存在。如果flag存在,而可以说明被读取的field是否真实存在。
func (*RedisHasher[K, V]) HKeys ¶
func (t *RedisHasher[K, V]) HKeys(ctx context.Context, key string) ([]K, error)
func (*RedisHasher[K, V]) HKeysAndSetIfNA ¶
func (*RedisHasher[K, V]) HMustSetsMap ¶
func (t *RedisHasher[K, V]) HMustSetsMap(ctx context.Context, key string, valueMap map[K]V, mustFields []K, placeholderVal V) error
func (*RedisHasher[K, V]) HSet ¶
func (t *RedisHasher[K, V]) HSet(ctx context.Context, key string, field K, value V) error
func (*RedisHasher[K, V]) HSetsMap ¶
func (t *RedisHasher[K, V]) HSetsMap(ctx context.Context, key string, valueMap map[K]V) error
func (*RedisHasher[K, V]) ValueDecoder ¶
func (t *RedisHasher[K, V]) ValueDecoder(decoder RedisDecoder[V]) *RedisHasher[K, V]
func (*RedisHasher[K, V]) ValueEncoder ¶
func (t *RedisHasher[K, V]) ValueEncoder(encoder RedisEncoder[V]) *RedisHasher[K, V]
type RedisKey ¶
type RedisKey[K comparable] struct { // contains filtered or unexported fields }
type RedisList ¶
type RedisList[V any] struct { RedisBatchValue[V] // contains filtered or unexported fields }
func (*RedisList[V]) WithBatchSize ¶
type RedisLock ¶
type RedisLock struct {
// contains filtered or unexported fields
}
func NewRedisLock ¶
func (*RedisLock) FetchOrRefresh ¶
type RedisMSZSet ¶
type RedisMSZSet[M comparable, S any] struct { // contains filtered or unexported fields }
func NewIDZSet ¶
func NewIDZSet(client redis.Cmdable) *RedisMSZSet[int64, int64]
func NewMSZSet ¶
func NewMSZSet[M comparable, S any](client redis.Cmdable, memberEncoder RedisEncoder[M], memberDecoder RedisDecoder[M], scoreEncoder RedisFloatEncoder[S], scoreDecoder RedisFloatDecoder[S], batchSize ...int) *RedisMSZSet[M, S]
func (*RedisMSZSet[M, S]) WithBatchSize ¶ added in v0.1.1
func (ms *RedisMSZSet[M, S]) WithBatchSize(batchSize int) *RedisMSZSet[M, S]
func (*RedisMSZSet[M, S]) ZMScore ¶
func (ms *RedisMSZSet[M, S]) ZMScore(ctx context.Context, key string, inputs ...M) (map[M]S, error)
func (*RedisMSZSet[M, S]) ZRangeArgs ¶
func (ms *RedisMSZSet[M, S]) ZRangeArgs(ctx context.Context, args *ZArgs, placeHolder ...M) ([]M, error)
type RedisMsg ¶
type RedisMsg map[string]interface{}
func (RedisMsg) IsStopSignal ¶
func (RedisMsg) StopSignal ¶
type RedisSet ¶
type RedisSet[V any] struct { RedisBatchValue[V] // contains filtered or unexported fields }
func NewRedisSet ¶
func NewRedisSet[V any](client redis.Cmdable, encoder RedisEncoder[V], decoder RedisDecoder[V]) *RedisSet[V]
func (*RedisSet[V]) SAddWithEmpty ¶
func (*RedisSet[V]) WithBatchSize ¶
type RedisString ¶
type RedisString[K comparable, V any] struct { RedisKey[K] // contains filtered or unexported fields }
func NewRedisString ¶
func NewRedisString[K comparable, V any](client redis.Cmdable, keyEncoder RedisEncoder[K], valueEncoder RedisEncoder[V], valueDecoder RedisDecoder[V]) *RedisString[K, V]
func NewStringReader ¶
func NewStringReader[K comparable, V any](client redis.Cmdable, keyEncoder RedisEncoder[K], valueDecoder RedisDecoder[V]) *RedisString[K, V]
func NewStringWriter ¶
func NewStringWriter[K comparable, V any](client redis.Cmdable, keyEncoder RedisEncoder[K], valueEncoder RedisEncoder[V]) *RedisString[K, V]
func (*RedisString[K, V]) Client ¶
func (s *RedisString[K, V]) Client(client redis.Cmdable) *RedisString[K, V]
func (*RedisString[K, V]) Get ¶
func (s *RedisString[K, V]) Get(ctx context.Context, k K) (exist bool, t V, err error)
func (*RedisString[K, V]) Gets ¶
func (s *RedisString[K, V]) Gets(ctx context.Context, ks ...K) (notcached []K, cached map[K]V, err error)
func (*RedisString[K, V]) GetsAndSets ¶
func (s *RedisString[K, V]) GetsAndSets(ctx context.Context, dbLoader MapLoader[K, V], ks ...K) (map[K]V, error)
func (*RedisString[K, V]) KeyEncoder ¶
func (s *RedisString[K, V]) KeyEncoder(encoder RedisEncoder[K]) *RedisString[K, V]
func (*RedisString[K, V]) Sets ¶
func (s *RedisString[K, V]) Sets(ctx context.Context, values map[K]V) error
func (*RedisString[K, V]) ValueDecoder ¶
func (s *RedisString[K, V]) ValueDecoder(decoder RedisDecoder[V]) *RedisString[K, V]
func (*RedisString[K, V]) ValueEncoder ¶
func (s *RedisString[K, V]) ValueEncoder(encoder RedisEncoder[V]) *RedisString[K, V]
type RedisZDecoder ¶
type RedisZEncoder ¶
RedisZEncoder returns ok==false means ignoring the value
type RedisZSet ¶
type RedisZSet[Z any] struct { // contains filtered or unexported fields }
func NewIdScoreZSet ¶
func NewRedisZSet ¶
func (*RedisZSet[Z]) BZPopMin ¶
func (zs *RedisZSet[Z]) BZPopMin(ctx context.Context, timeout time.Duration, key string) ([]Z, error)
BZPopMin 为了体现zset中没有数据,超时返回时的redis.Nil错误,统一返回slice,可以用nil表示没有返回值的情况
func (*RedisZSet[Z]) WithBatchSize ¶
func (*RedisZSet[Z]) ZAddNXWithEmpty ¶
func (*RedisZSet[Z]) ZAddWithEmpty ¶
type ZArgs ¶
type ZArgs struct {
// contains filtered or unexported fields
}