cache

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Ping(ctxt context.Context) error
	Push(ctx context.Context, key string, values ...interface{}) error
	Pop(ctx context.Context, key string) (string, error)
	Count(ctx context.Context, key string) (int64, error)
	Del(ctxt context.Context, keys ...string) (int64, error)
	Exists(ctx context.Context, keys ...string) (int64, error)
	Get(ctxt context.Context, key string) (string, error)
	Set(ctx context.Context, key string, value interface{}, expiration time.Duration) (string, error)
	HDel(ctx context.Context, key string, fields ...string) (int64, error)
	HGet(ctx context.Context, key, field string) (string, error)
	HGetAll(ctx context.Context, key string) (map[string]string, error)
	HSet(ctx context.Context, key string, values ...interface{}) (int64, error)
	LPop(ctx context.Context, key string) (string, error)
	RPush(ctx context.Context, key string, fields ...string) (int64, error)
}

func New

func New(ctxt context.Context, cfg *Properties) (Cache, *national.Message)

type CacheMock

type CacheMock struct {
}

func (CacheMock) Count

func (c CacheMock) Count(ctx context.Context, key string) (int64, error)

func (CacheMock) Del

func (c CacheMock) Del(ctxt context.Context, keys ...string) (int64, error)

func (CacheMock) Exists

func (c CacheMock) Exists(ctx context.Context, keys ...string) (int64, error)

func (CacheMock) Get

func (c CacheMock) Get(ctxt context.Context, key string) (string, error)

func (CacheMock) HDel

func (c CacheMock) HDel(ctx context.Context, key string, fields ...string) (int64, error)

func (CacheMock) HGet

func (c CacheMock) HGet(ctx context.Context, key, field string) (string, error)

func (CacheMock) HGetAll

func (c CacheMock) HGetAll(ctx context.Context, key string) (map[string]string, error)

func (CacheMock) HSet

func (c CacheMock) HSet(ctx context.Context, key string, values ...interface{}) (int64, error)

func (CacheMock) LPop

func (c CacheMock) LPop(ctx context.Context, key string) (string, error)

func (CacheMock) Ping

func (c CacheMock) Ping(ctxt context.Context) error

func (CacheMock) Pop

func (c CacheMock) Pop(ctx context.Context, key string) (string, error)

func (CacheMock) Push

func (c CacheMock) Push(ctx context.Context, key string, values ...interface{}) error

func (CacheMock) RPush

func (c CacheMock) RPush(ctx context.Context, key string, fields ...string) (int64, error)

func (CacheMock) Set

func (c CacheMock) Set(ctx context.Context, key string, value interface{}, expiration time.Duration) (string, error)

type Credential

type Credential struct {
	Username string `yaml:"username"`
	Password string `yaml:"password"`
}

type Pool

type Pool struct {
	Size                  int           `json:"size" yaml:"size" default:"60"`
	MaxRetries            int           `json:"max_retries" yaml:"max_retries" default:"3"`
	MinIdleConnections    int           `json:"min_idle_connections" yaml:"min_idle_connections" default:"10"`
	MaxIdleConnections    int           `json:"max_idle_connections" yaml:"max_idle_connections" default:"20"`
	MaxActiveConnections  int           `json:"max_active_connections" yaml:"max_active_connections" default:"30"`
	MaxConnectionIdleTime time.Duration `json:"max_connection_idle_time" yaml:"max_connection_idle_time" default:"1h"`
	MaxConnectionLifeTime time.Duration `json:"max_connection_life_time" yaml:"max_connection_life_time" default:"10h"`
}

type Properties

type Properties struct {
	Type       Type               `yaml:"type" default:"redis"`
	Addresses  lists.List[string] `yaml:"addresses"`
	Database   int                `yaml:"database" default:"0"`
	Credential Credential         `yaml:"credential"`
	Pool       Pool               `yaml:"pool"`
}

type RedisCache

type RedisCache struct {
	// contains filtered or unexported fields
}

func NewRedis

func NewRedis(ctxt context.Context, cfg *Properties) (*RedisCache, *national.Message)

func (*RedisCache) Count

func (r *RedisCache) Count(ctx context.Context, key string) (int64, error)

func (*RedisCache) Del

func (r *RedisCache) Del(ctxt context.Context, keys ...string) (int64, error)

func (*RedisCache) Exists

func (r *RedisCache) Exists(ctx context.Context, keys ...string) (int64, error)

func (*RedisCache) Get

func (r *RedisCache) Get(ctxt context.Context, key string) (string, error)

func (*RedisCache) HDel

func (r *RedisCache) HDel(ctx context.Context, key string, fields ...string) (int64, error)

func (*RedisCache) HGet

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

func (*RedisCache) HGetAll

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

func (*RedisCache) HSet

func (r *RedisCache) HSet(ctx context.Context, key string, values ...interface{}) (int64, error)

func (*RedisCache) InsertHead

func (r *RedisCache) InsertHead(ctx context.Context, key string, values ...interface{}) error

func (*RedisCache) LPop

func (r *RedisCache) LPop(ctx context.Context, key string) (string, error)

func (*RedisCache) Lock

func (r *RedisCache) Lock(ctx context.Context, source, owner string, timeout time.Duration) (bool, error)

func (*RedisCache) Ping

func (r *RedisCache) Ping(ctxt context.Context) error

func (*RedisCache) Pop

func (r *RedisCache) Pop(ctx context.Context, key string) (string, error)

func (*RedisCache) Push

func (r *RedisCache) Push(ctx context.Context, key string, values ...interface{}) error

func (*RedisCache) RPush

func (r *RedisCache) RPush(ctx context.Context, key string, fields ...string) (int64, error)

func (*RedisCache) Set

func (r *RedisCache) Set(ctx context.Context, key string, value interface{}, expiration time.Duration) (string, error)

func (*RedisCache) Unlock

func (r *RedisCache) Unlock(ctx context.Context, source, owner string) (bool, error)

type Type

type Type string
const (
	Redis Type = "redis"
)

Jump to

Keyboard shortcuts

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