cache

package
v0.0.0-...-09ba4a8 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RedisLock *redsync.Redsync

Functions

func Del

func Del(key string) error

Del delete key in cache

func Expire

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

func Get

func Get(key string) (string, error)

Get val in cache

func HashDel

func HashDel(hk, key string) error

HashDel delete one key:value pair in hashtable cache

func HashGet

func HashGet(hk, key string) (string, error)

HashGet get val in hashtable cache

func HashGetAll

func HashGetAll(hk string) (map[string]string, error)

func HashMSet

func HashMSet(hk string, value map[string]interface{}) error

func HashSet

func HashSet(hk, key string, value interface{}) error

func Increase

func Increase(key string) error

Increase value

func InitRedisLock

func InitRedisLock()

func SAdd

func SAdd(key string, member string) error

func SMembers

func SMembers(key string) ([]string, error)

func SRem

func SRem(key string, member string) error

func Set

func Set(key, val string, expire int) error

Set val in cache

Types

type Adapter

type Adapter interface {
	Connect()
	Get(key string) (string, error)
	Set(key string, val string, expire int) error
	Del(key string) error
	HashGet(hk, key string) (string, error)
	HashDel(hk, key string) error
	Increase(key string) error
	Expire(key string, dur time.Duration) error
	SMembers(key string) ([]string, error)
	HashGetAll(hk string) (map[string]string, error)
	HashSet(hk, key string, value interface{}) error
	SAdd(key string, member string) error
	SRem(key string, member string) error
	HashMSet(hk string, pairs map[string]interface{}) error
	Close()
}

func Init

func Init() (Adapter, func())

type Redis

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

Redis cache implement

func (*Redis) Close

func (r *Redis) Close()

func (*Redis) Connect

func (r *Redis) Connect()

Connect connect to redis

func (*Redis) Del

func (r *Redis) Del(key string) error

Del delete key in redis

func (*Redis) Expire

func (r *Redis) Expire(key string, dur time.Duration) error

Expire set ttl

func (*Redis) Get

func (r *Redis) Get(key string) (string, error)

Get from key

func (*Redis) HashDel

func (r *Redis) HashDel(hk, key string) error

HashDel delete key in specify redis's hashtable

func (*Redis) HashGet

func (r *Redis) HashGet(hk, key string) (string, error)

HashGet from key

func (*Redis) HashGetAll

func (r *Redis) HashGetAll(hk string) (map[string]string, error)

func (*Redis) HashMSet

func (r *Redis) HashMSet(hk string, params map[string]interface{}) error

func (*Redis) HashSet

func (r *Redis) HashSet(hk, key string, value interface{}) error

func (*Redis) Increase

func (r *Redis) Increase(key string) error

Increase increase value

func (*Redis) SAdd

func (r *Redis) SAdd(key string, member string) error

func (*Redis) SMembers

func (r *Redis) SMembers(key string) ([]string, error)

func (*Redis) SRem

func (r *Redis) SRem(key string, member string) error

func (*Redis) Set

func (r *Redis) Set(key string, val string, expire int) error

Set value with key and expire time

Jump to

Keyboard shortcuts

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