Documentation ¶
Index ¶
- Variables
- func PrefixedInt64Key(prefix string, key int64) string
- type ErrCacher
- type ErrMarshaler
- type ExpiringHash
- func (h *ExpiringHash[K1, K2]) Clear(ctx context.Context) (int, error)
- func (h *ExpiringHash[K1, K2]) Forget(key K1, hashKey K2)
- func (h *ExpiringHash[K1, K2]) GC() func(context.Context) (int, error)
- func (h *ExpiringHash[K1, K2]) Len(ctx context.Context, key K1) (size int64, retErr error)
- func (h *ExpiringHash[K1, K2]) Refresh(nextRefresh time.Time) IOFunc
- func (h *ExpiringHash[K1, K2]) Scan(ctx context.Context, key K1, cb ScanCallback) (keysDeleted int, retErr error)
- func (h *ExpiringHash[K1, K2]) Set(key K1, hashKey K2, value []byte) IOFunc
- func (h *ExpiringHash[K1, K2]) Unset(key K1, hashKey K2) IOFunc
- type ExpiringHashInterface
- type ExpiringValue
- func (*ExpiringValue) Descriptor() ([]byte, []int)deprecated
- func (x *ExpiringValue) GetExpiresAt() int64
- func (x *ExpiringValue) GetValue() []byte
- func (*ExpiringValue) ProtoMessage()
- func (x *ExpiringValue) ProtoReflect() protoreflect.Message
- func (x *ExpiringValue) Reset()
- func (x *ExpiringValue) String() string
- type ExpiringValueTimestamp
- func (*ExpiringValueTimestamp) Descriptor() ([]byte, []int)deprecated
- func (x *ExpiringValueTimestamp) GetExpiresAt() int64
- func (*ExpiringValueTimestamp) ProtoMessage()
- func (x *ExpiringValueTimestamp) ProtoReflect() protoreflect.Message
- func (x *ExpiringValueTimestamp) Reset()
- func (x *ExpiringValueTimestamp) String() string
- type IOFunc
- type KeyToRedisKey
- type RpcApi
- type ScanCallback
- type TokenLimiter
Constants ¶
This section is empty.
Variables ¶
var File_internal_tool_redistool_redistool_proto protoreflect.FileDescriptor
Functions ¶
func PrefixedInt64Key ¶
Types ¶
type ErrCacher ¶ added in v15.5.0
type ErrCacher[K any] struct { Log *zap.Logger ErrRep errz.ErrReporter Client redis.UniversalClient ErrMarshaler ErrMarshaler KeyToRedisKey KeyToRedisKey[K] }
func (*ErrCacher[K]) CacheError ¶ added in v15.5.0
type ErrMarshaler ¶ added in v15.5.0
type ExpiringHash ¶
type ExpiringHash[K1 comparable, K2 comparable] struct { // contains filtered or unexported fields }
func NewExpiringHash ¶
func NewExpiringHash[K1 comparable, K2 comparable](client redis.UniversalClient, key1ToRedisKey KeyToRedisKey[K1], key2ToRedisKey KeyToRedisKey[K2], ttl time.Duration) *ExpiringHash[K1, K2]
func (*ExpiringHash[K1, K2]) Clear ¶ added in v15.8.0
func (h *ExpiringHash[K1, K2]) Clear(ctx context.Context) (int, error)
func (*ExpiringHash[K1, K2]) Forget ¶ added in v15.3.0
func (h *ExpiringHash[K1, K2]) Forget(key K1, hashKey K2)
func (*ExpiringHash[K1, K2]) GC ¶
func (h *ExpiringHash[K1, K2]) GC() func(context.Context) (int, error)
func (*ExpiringHash[K1, K2]) Len ¶ added in v15.2.0
func (h *ExpiringHash[K1, K2]) Len(ctx context.Context, key K1) (size int64, retErr error)
func (*ExpiringHash[K1, K2]) Refresh ¶
func (h *ExpiringHash[K1, K2]) Refresh(nextRefresh time.Time) IOFunc
func (*ExpiringHash[K1, K2]) Scan ¶
func (h *ExpiringHash[K1, K2]) Scan(ctx context.Context, key K1, cb ScanCallback) (keysDeleted int, retErr error)
func (*ExpiringHash[K1, K2]) Set ¶
func (h *ExpiringHash[K1, K2]) Set(key K1, hashKey K2, value []byte) IOFunc
func (*ExpiringHash[K1, K2]) Unset ¶
func (h *ExpiringHash[K1, K2]) Unset(key K1, hashKey K2) IOFunc
type ExpiringHashInterface ¶
type ExpiringHashInterface[K1 any, K2 any] interface { Set(key K1, hashKey K2, value []byte) IOFunc Unset(key K1, hashKey K2) IOFunc // Forget only removes the item from the in-memory map. Forget(key K1, hashKey K2) Scan(ctx context.Context, key K1, cb ScanCallback) (int, error) Len(ctx context.Context, key K1) (int64, error) // GC returns a function that iterates all relevant stored data and deletes expired entries. // The returned function can be called concurrently as it does not interfere with the hash's operation. // The function returns number of deleted Redis (hash) keys, including when an error occurs. // It only inspects/GCs hashes where it has entries. Other concurrent clients GC same and/or other corresponding hashes. // Hashes that don't have a corresponding client (e.g. because it crashed) will expire because of TTL on the hash key. GC() func(context.Context) (int, error) // Clear clears all data in this hash and deletes it from the backing store. Clear(context.Context) (int, error) Refresh(nextRefresh time.Time) IOFunc }
ExpiringHashInterface represents a two-level hash: key K1 -> hashKey K2 -> value []byte. key identifies the hash; hashKey identifies the key in the hash; value is the value for the hashKey. It is not safe for concurrent use directly, but it allows to perform I/O with backing store concurrently by returning functions for doing that.
type ExpiringValue ¶
type ExpiringValue struct { ExpiresAt int64 `protobuf:"varint,1,opt,name=expires_at,json=expiresAt,proto3" json:"expires_at,omitempty"` Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` // contains filtered or unexported fields }
func (*ExpiringValue) Descriptor
deprecated
func (*ExpiringValue) Descriptor() ([]byte, []int)
Deprecated: Use ExpiringValue.ProtoReflect.Descriptor instead.
func (*ExpiringValue) GetExpiresAt ¶
func (x *ExpiringValue) GetExpiresAt() int64
func (*ExpiringValue) GetValue ¶
func (x *ExpiringValue) GetValue() []byte
func (*ExpiringValue) ProtoMessage ¶
func (*ExpiringValue) ProtoMessage()
func (*ExpiringValue) ProtoReflect ¶
func (x *ExpiringValue) ProtoReflect() protoreflect.Message
func (*ExpiringValue) Reset ¶
func (x *ExpiringValue) Reset()
func (*ExpiringValue) String ¶
func (x *ExpiringValue) String() string
type ExpiringValueTimestamp ¶ added in v15.4.0
type ExpiringValueTimestamp struct { ExpiresAt int64 `protobuf:"varint,1,opt,name=expires_at,json=expiresAt,proto3" json:"expires_at,omitempty"` // contains filtered or unexported fields }
func (*ExpiringValueTimestamp) Descriptor
deprecated
added in
v15.4.0
func (*ExpiringValueTimestamp) Descriptor() ([]byte, []int)
Deprecated: Use ExpiringValueTimestamp.ProtoReflect.Descriptor instead.
func (*ExpiringValueTimestamp) GetExpiresAt ¶ added in v15.4.0
func (x *ExpiringValueTimestamp) GetExpiresAt() int64
func (*ExpiringValueTimestamp) ProtoMessage ¶ added in v15.4.0
func (*ExpiringValueTimestamp) ProtoMessage()
func (*ExpiringValueTimestamp) ProtoReflect ¶ added in v15.4.0
func (x *ExpiringValueTimestamp) ProtoReflect() protoreflect.Message
func (*ExpiringValueTimestamp) Reset ¶ added in v15.4.0
func (x *ExpiringValueTimestamp) Reset()
func (*ExpiringValueTimestamp) String ¶ added in v15.4.0
func (x *ExpiringValueTimestamp) String() string
type IOFunc ¶ added in v15.4.0
IOFunc is a function that should be called to perform the I/O of the requested operation. It is safe to call concurrently as it does not interfere with the hash's operation.
type KeyToRedisKey ¶
KeyToRedisKey is used to convert typed key (key1 or key2) into a string. HSET key1 key2 value.
type ScanCallback ¶
type TokenLimiter ¶
type TokenLimiter struct {
// contains filtered or unexported fields
}
TokenLimiter is a redis-based rate limiter implementing the algorithm in https://redislabs.com/redis-best-practices/basic-rate-limiting/
func NewTokenLimiter ¶
func NewTokenLimiter(redisClient redis.UniversalClient, keyPrefix string, limitPerMinute uint64, getApi func(context.Context) RpcApi) *TokenLimiter
NewTokenLimiter returns a new TokenLimiter