redisutil

package
v7.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GzipJSONGetSet

func GzipJSONGetSet[T any](ctx context.Context, c RedisSetter, key string, v T) (bool, error)

func GzipJSONSet

func GzipJSONSet[T any](ctx context.Context, c RedisSetter, key string, v T, expiration time.Duration) error

func IndexVacuum

func IndexVacuum(ctx context.Context, c RedisIndexer, indexKey string, dataKeyPrefix Prefix) error

func JSONGet

func JSONGet[T any](ctx context.Context, c RedisGetter, key string) (*T, error)

func MarshalGzipJSON

func MarshalGzipJSON[T any](v T) (string, error)

func UnmarshalGzipJSON

func UnmarshalGzipJSON[T any](payload string) (*T, error)

Types

type Broadcast

type Broadcast[T any] struct {
	// contains filtered or unexported fields
}

func NewBroadcast

func NewBroadcast[T any](client BroadcastRediser, key string) (*Broadcast[T], error)

func (*Broadcast[T]) Add

func (b *Broadcast[T]) Add(ctx context.Context, value *T) error

func (*Broadcast[T]) Read

func (b *Broadcast[T]) Read(ctx context.Context, id string) (*T, string, error)

type BroadcastRediser

type BroadcastRediser interface {
	XAdd(ctx context.Context, a *redis.XAddArgs) *redis.StringCmd
	XRead(ctx context.Context, a *redis.XReadArgs) *redis.XStreamSliceCmd
}

type Prefix

type Prefix string

func (Prefix) Add

func (p Prefix) Add(elem ...string) Prefix

func (Prefix) Key

func (p Prefix) Key(elem ...string) string

func (Prefix) Keys

func (p Prefix) Keys(list []string) []string

type RedisGetter

type RedisGetter interface {
	Get(context.Context, string) *redis.StringCmd
}

type RedisIndexer

type RedisIndexer interface {
	SMembers(ctx context.Context, key string) *redis.StringSliceCmd
	MGet(ctx context.Context, keys ...string) *redis.SliceCmd
	SRem(ctx context.Context, key string, members ...interface{}) *redis.IntCmd
}

type RedisSetter

type RedisSetter interface {
	Set(context.Context, string, interface{}, time.Duration) *redis.StatusCmd
	GetSet(context.Context, string, interface{}) *redis.StringCmd
}

Jump to

Keyboard shortcuts

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