cache

package
v1.1.196 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: MIT Imports: 17 Imported by: 1

Documentation

Index

Constants

View Source
const IsNil = redis.Nil

Variables

View Source
var DecrKeepTTLScript = redis.NewScript(`
    local val = redis.call("GET", KEYS[1])
    if not val then
        return -1
    end

    val = tonumber(val)

    if val > 0 then
        return redis.call("DECR", KEYS[1])
    else
        return -1
    end
`)
View Source
var FromId string
View Source
var IncrSetTTLScript = redis.NewScript(`
    local ttl = tonumber(ARGV[1])

    local newVal = redis.call("INCR", KEYS[1])

    if ttl > 0 then
        redis.call("PEXPIRE", KEYS[1], ttl)
    end

    return newVal
`)

Functions

func AllCache

func AllCache(search string, page, rows int) (et.List, error)

* * AllCache * @params device string * @params key string * @params val string * @return error *

func Close

func Close()

* * Close * @return void *

func Decr added in v1.1.91

func Decr(key string) int64

* * Decr * @params key string * @return int64 *

func DecrCtx added in v1.1.91

func DecrCtx(ctx context.Context, key string) int64

* * DecrCtx * @params ctx context.Context, key string * @return int64 *

func Delete

func Delete(key string) (int64, error)

* * Delete * @params key string * @return int64, error *

func DeleteCtx

func DeleteCtx(ctx context.Context, key string) (int64, error)

* * DeleteCtx * @params ctx context.Context, key string * @return int64, error *

func DeleteVerify

func DeleteVerify(device string, key string) (int64, error)

* * DeleteVerify * @params device string * @params key string * @return int64, error *

func Empty

func Empty(match string) error

* * Empty * @return error *

func Exists added in v1.1.38

func Exists(key string) bool

* * Exists * @params key string * @return bool *

func ExistsCtx added in v1.1.38

func ExistsCtx(ctx context.Context, key string) bool

* * ExistsCtx * @params ctx context.Context, key string * @return bool *

func Expire added in v1.1.124

func Expire(key string, second time.Duration) error

* * Expire * @params key string, second time.Duration * @return error *

func ExpireCtx added in v1.1.124

func ExpireCtx(ctx context.Context, key string, second time.Duration) error

* * ExpireCtx * @params ctx context.Context, key string, second time.Duration * @return error *

func GenId added in v1.1.21

func GenId(args ...interface{}) string

* * GenId * @params args ...interface{} * @return string *

func GenKey added in v1.1.0

func GenKey(args ...interface{}) string

* * GenKey * @params args ...interface{} * @return string *

func Get

func Get(key, def string) (string, error)

* * Get * @params key string, def string * @return string, error *

func GetBool added in v1.1.186

func GetBool(key string) (bool, error)

* * @params key string * @return bool, error *

func GetCtx

func GetCtx(ctx context.Context, key, def string) (string, error)

* * GetCtx * @params ctx context.Context, key string * @params def string * @return string, error *

func GetFloat added in v1.1.186

func GetFloat(key string) (float64, error)

* * GetFloat * @params key string * @result float64, error *

func GetInt added in v1.1.186

func GetInt(key string) (int, error)

* * GetInt * @params key string * @return int64, error *

func GetInt64 added in v1.1.186

func GetInt64(key string) (int64, error)

* * GetInt64 * @params key string * @return int64, error *

func GetItem

func GetItem(key string) (et.Item, error)

* * GetItem * @params key string * @return Item, error *

func GetItems

func GetItems(key string) (et.Items, error)

* * GetItems * @params key string * @return Items, error *

func GetJson

func GetJson(key string) (et.Json, error)

* * GetJson * @params key string * @return Json, error *

func GetVerify

func GetVerify(device string, key string) (string, error)

* * GetVerify * @params device string * @params key string * @return string, error *

func HDelete

func HDelete(key, atr string) error

* * HDelete * @params key string * @params atr string * @return error *

func HDeleteCtx

func HDeleteCtx(ctx context.Context, key, atr string) error

* * HDeleteCtx * @params ctx context.Context, key string * @params atr string * @return error *

func HGet

func HGet(key string) (map[string]string, error)

* * HGet * @params key string * @return map[string]string, error *

func HGetAtrib

func HGetAtrib(key, atr string) (string, error)

* * HGetAtrib * @params key string * @params atr string * @return string, error *

func HGetCtx

func HGetCtx(ctx context.Context, key string) (map[string]string, error)

* * HGetCtx * @params ctx context.Context, key string * @return map[string]string, error *

func HSet

func HSet(key string, val map[string]string) error

* * HSet * @params key string, map[string]string * @return error *

func HSetAtrib

func HSetAtrib(key, atr, val string) error

* * HSetAtrib * @params key string * @params atr string * @params val string * @return error *

func HSetCtx

func HSetCtx(ctx context.Context, key string, val map[string]string) error

* * HSetCtx * @params ctx context.Context, key string, val map[string]string * @return error *

func HandlerAll

func HandlerAll(w http.ResponseWriter, r *http.Request)

* * HandlerAll * @params w http.ResponseWriter * @params r *http.Request *

func HandlerDelete

func HandlerDelete(w http.ResponseWriter, r *http.Request)

* * HandlerDelete * @params w http.ResponseWriter * @params r *http.Request *

func HandlerGet

func HandlerGet(w http.ResponseWriter, r *http.Request)

* * HandlerGet * @params w http.ResponseWriter * @params r *http.Request *

func HealthCheck added in v1.1.124

func HealthCheck() bool

* * HealthCheck * @return bool *

func Incr added in v1.1.91

func Incr(key string, second time.Duration) int64

* * Incr * @params key string, second time.Duration (second) * @return int64 *

func IncrCtx added in v1.1.91

func IncrCtx(ctx context.Context, key string, second time.Duration) int64

* * IncrCtx * @params ctx context.Context, key string, second time.Duration * @return int64 *

func IsLoad added in v1.1.91

func IsLoad() bool

* * IsLoad * @return bool *

func LPush added in v1.1.115

func LPush(key, val string) error

* * LPush * @params key string, val string * @return error *

func LPushCtx added in v1.1.115

func LPushCtx(ctx context.Context, key string, val string) error

* * LPushCtx * @params ctx context.Context, key string, val string * @return error *

func LRange added in v1.1.115

func LRange(key string, start, stop int64) ([]string, error)

* * LRange * @params key string, start int64, stop int64 * @return []string, error *

func LRangeCtx added in v1.1.115

func LRangeCtx(ctx context.Context, key string, start int64, stop int64) ([]string, error)

* * LRangeCtx * @params ctx context.Context, key string, start int64, stop int64 * @return []string, error *

func LRem added in v1.1.115

func LRem(key, val string) error

* * LRem * @params key string, val string * @return error *

func LRemCtx added in v1.1.115

func LRemCtx(ctx context.Context, key string, val string) error

* * LPushCtx * @params ctx context.Context, key string, val string * @return error *

func LTrim added in v1.1.115

func LTrim(key string, start, stop int64) error

* * LTrim * @params key string, start int64, stop int64 * @return error *

func LTrimCtx added in v1.1.115

func LTrimCtx(ctx context.Context, key string, start int64, stop int64) error

* * LTrimCtx * @params ctx context.Context, key string, start int64, stop int64 * @return error *

func More

func More(key string, second time.Duration) int

* * More * @params key string, time.Duration * @return int *

func Set

func Set(key string, val interface{}, second time.Duration) error

* * Set * @params key string, val interface{}, second time.Duration * @return error *

func SetCtx

func SetCtx(ctx context.Context, key, val string, second time.Duration) error

* * SetCtx * @params ctx context.Context, key string, val string, second time.Duration * @return error *

func SetD

func SetD(key string, val interface{}) error

* * SetD * @params key string, val interface{} * @return error *

func SetH

func SetH(key string, val interface{}) error

* * SetH * @params key string, val interface{} * @return error *

func SetM

func SetM(key string, val interface{}) error

* * SetM * @params key string, val interface{} * @return error *

func SetVerify

func SetVerify(device, key, val string, duration time.Duration) error

* * SetVerify * @params device string * @params key string * @params val string * @params duration time.Duration * @return error *

func SetW

func SetW(key string, val interface{}) error

* * SetW * @params key string, val interface{} * @return error *

func SetY

func SetY(key string, val interface{}) error

* * SetY * @params key string, interface{} * @return error *

Types

type Conn

type Conn struct {
	*redis.Client
	// contains filtered or unexported fields
}

func ConnectTo added in v1.1.30

func ConnectTo(host, password string, dbname int) (*Conn, error)

* * ConnectTo * @param host, password string, dbname int * @return *Conn, error *

func Load

func Load() (*Conn, error)

* * Load * @return *Conn, error *

func (*Conn) Pub added in v1.1.30

func (s *Conn) Pub(channel string, message []byte) error

* * Pub * @param channel string * @param message interface{} * @return error *

func (*Conn) Sub added in v1.1.30

func (s *Conn) Sub(channel string, f func(*redis.Message))

* * Sub * @param channel string * @param f func(interface{}) *

func (*Conn) Unsub added in v1.1.30

func (s *Conn) Unsub(channel string) error

* * Unsub * @param channel string * @return error *

type Message added in v1.1.42

type Message struct {
	ID      string `json:"id"`
	Content string `json:"content"`
}

func (Message) ToJson added in v1.1.42

func (s Message) ToJson() (et.Json, error)

Jump to

Keyboard shortcuts

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