redis

package
v0.0.0-...-61e4c6b Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitRedis

func InitRedis() error

func Ping

func Ping(ctx context.Context) error

Types

type ConfigItem

type ConfigItem struct {
	Address  string `json:"address"`
	Password string `json:"password"`
	DB       int32  `json:"db"`
}

type Redis

type Redis struct {
	Config *redis.Options
	Client *redis.Client
}

Redis provides a cache backed by a Redis server.

func GetRedis

func GetRedis() (*Redis, error)

func New

func New(config *redis.Options) *Redis

New returns an initialized Redis cache object.

func (*Redis) Del

func (r *Redis) Del(ctx context.Context, key string) error

func (*Redis) Expire

func (r *Redis) Expire(ctx context.Context, key string, expire time.Duration) error

func (*Redis) Get

func (r *Redis) Get(ctx context.Context, key string) (string, error)

Get returns the value saved under a given key.

func (*Redis) GetBytes

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

func (*Redis) HDel

func (r *Redis) HDel(ctx context.Context, key string, field ...string) error

func (*Redis) HGet

func (r *Redis) HGet(ctx context.Context, key, field string) (string, error)

func (*Redis) HGetAll

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

func (*Redis) HSet

func (r *Redis) HSet(ctx context.Context, key, field, value string, expire time.Duration) error

func (*Redis) HSetNX

func (r *Redis) HSetNX(ctx context.Context, key, field, value string, expire time.Duration) error

func (*Redis) Incr

func (r *Redis) Incr(ctx context.Context, key string) (int64, error)

func (*Redis) LLen

func (r *Redis) LLen(ctx context.Context, key string) (int64, error)

func (*Redis) LPush

func (r *Redis) LPush(ctx context.Context, key string, values ...any) error

func (*Redis) LRange

func (r *Redis) LRange(ctx context.Context, key string, start, stop int64) ([]string, error)

func (*Redis) MGet

func (r *Redis) MGet(ctx context.Context, keys []string) ([]any, error)

func (*Redis) Ping

func (r *Redis) Ping(ctx context.Context) error

func (*Redis) RPush

func (r *Redis) RPush(ctx context.Context, key string, values ...any) error

func (*Redis) Set

func (r *Redis) Set(ctx context.Context, key string, value any, expire time.Duration) error

Set saves an arbitrary value under a specific key.

func (*Redis) SetNX

func (r *Redis) SetNX(ctx context.Context, key string, value any, expire time.Duration) (bool, error)

func (*Redis) TTL

func (r *Redis) TTL(ctx context.Context, key string) (time.Duration, error)

func (*Redis) ZAdd

func (r *Redis) ZAdd(ctx context.Context, key string, score float64, data string) error

func (*Redis) ZCount

func (r *Redis) ZCount(ctx context.Context, key, min, max string) (int64, error)

func (*Redis) ZRange

func (r *Redis) ZRange(ctx context.Context, key string, start, stop int64) ([]string, error)

func (*Redis) ZRem

func (r *Redis) ZRem(ctx context.Context, key string, members ...any) error

Jump to

Keyboard shortcuts

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