cache

package
v2.15.2 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2024 License: CC0-1.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Caches

type Caches interface {
	Get(ctx context.Context, key string) (string, error)
	Del(ctx context.Context, key string) (int64, error)
	HSet(ctx context.Context, key, field, value string) (string, error)
	Set(ctx context.Context, key, value string, expire ...int) (string, error)
	AddInSet(ctx context.Context, key, value string) (int, error)
	GetSetMembers(ctx context.Context, key string) ([]string, error)
	GetSetLength(ctx context.Context, key string) (int, error)
	GetNElementOfSet(ctx context.Context, key string, n int) ([]string, error)
	PushNElementToSet(ctx context.Context, values []interface{}) (int, error)
}

type Handler

type Handler interface {
	Get() redigo.Conn
	GetContext(context.Context) (redigo.Conn, error)
}

Handler handler for cache

type Options added in v2.4.1

type Options func(*RedisCfg)

func WithAddress added in v2.4.1

func WithAddress(address string) Options

func WithMaxActive added in v2.4.1

func WithMaxActive(maxActive int) Options

func WithMaxIdle added in v2.4.1

func WithMaxIdle(maxIdle int) Options

func WithPassword added in v2.4.4

func WithPassword(password string) Options

func WithTimeout added in v2.4.1

func WithTimeout(timeout int) Options

func WithUsername added in v2.4.4

func WithUsername(username string) Options

type RedisCfg

type RedisCfg struct {
	Address   string `yaml:"address"`
	Timeout   int    `yaml:"timeout"`
	MaxIdle   int    `yaml:"max_iddle"`
	MaxActive int    `yaml:"max_active"`
	Password  string `yaml:"password"`
	Username  string `yaml:"username"`
}

type Store

type Store struct {
	Pool Handler
	// contains filtered or unexported fields
}

Store object

func New

func New(options ...Options) *Store

func (*Store) AddInSet

func (r *Store) AddInSet(ctx context.Context, key, value string) (int, error)

AddInSet will be used to add value in set

func (*Store) Del

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

Del key value

func (*Store) Get

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

Get string value

func (*Store) GetNElementOfSet

func (r *Store) GetNElementOfSet(ctx context.Context, key string, n int) ([]string, error)

GetNElementOfSet to get the first N elements of set

func (*Store) GetSetLength

func (r *Store) GetSetLength(ctx context.Context, key string) (int, error)

GetSetLength will be used to get the set length

func (*Store) GetSetMembers

func (r *Store) GetSetMembers(ctx context.Context, key string) ([]string, error)

GetSetMembers will be used to get the set memebers

func (*Store) HSet

func (r *Store) HSet(ctx context.Context, key, field, value string) (string, error)

HSet set has map

func (*Store) PushNElementToSet

func (r *Store) PushNElementToSet(ctx context.Context, values []interface{}) (int, error)

PushNElementToSet will be used to push n elements to set

func (*Store) Set

func (r *Store) Set(ctx context.Context, key, value string, expire ...int) (string, error)

Set ill be used to set the value

Jump to

Keyboard shortcuts

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