redis_cache

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TenMinute    = time.Minute * 10
	ThirtyMinute = time.Minute * 30
	OneHour      = time.Hour
	TwelveHour   = time.Hour * 12
	OneDay       = OneHour * 24
	ThreeDay     = OneDay * 3
	SevenDay     = OneDay * 7
	SevenDayInt  = 60 * 60 * 24 * 7
)

Variables

This section is empty.

Functions

func NewRedisCache

func NewRedisCache(client redis.Cmdable) cache.Cache

NewRedisCache 实例化一个缓存结构

Types

type RedisCache

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

func (*RedisCache) Del

func (r *RedisCache) Del(key string) (bool, error)

Del 软删除, 就是设置一下状态为 invalidCacheCode

func (*RedisCache) Get

func (r *RedisCache) Get(key string, f func() (string, error)) (string, error)

Get 如果缓存不存在, 执行 set key value ex nx, 如果缓存是 invalidCacheCode, 执行 set key value ex 如果缓存无效或不存在, 会执行传入的函数去获取数据, 然后存到缓存

func (*RedisCache) MDel

func (r *RedisCache) MDel(keys ...string) ([]bool, error)

MDel 批量软删除

func (*RedisCache) MGet

func (r *RedisCache) MGet(keys ...string) ([]interface{}, error)

MGet 批量获取

Jump to

Keyboard shortcuts

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