cache

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: MulanPSL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheInterface

type CacheInterface interface {
	Set(key string, value interface{}, ttl time.Duration) error // 设置缓存
	Get(key string) string                                      // 获取缓存 string
	GetInt(key string) (int, error)                             // 获取int
	GetTtl(key string) time.Duration                            // 获取存活时间
	SetTtl(key string, ttl time.Duration) bool                  // 强制修改缓存时间
	Remove(key string) int                                      // 删除缓存
	Forever(key string, value interface{}) error                // 永久缓存
	SetStruct(key string, value interface{}, ttl time.Duration) error
	GetStruct(key string, dest interface{}) error
}

func GetCache

func GetCache(driver string, options ...*Options) CacheInterface

type Options

type Options struct {
	ConfName string
}

type RedisCache

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

func NewRedisCache

func NewRedisCache(conf string) *RedisCache

func (*RedisCache) Forever

func (r *RedisCache) Forever(key string, value interface{}) error

func (*RedisCache) Get

func (r *RedisCache) Get(key string) string

func (*RedisCache) GetInt

func (r *RedisCache) GetInt(key string) (int, error)

func (*RedisCache) GetStruct

func (r *RedisCache) GetStruct(k string, data interface{}) error

func (*RedisCache) GetTtl

func (r *RedisCache) GetTtl(key string) time.Duration

func (*RedisCache) Remove

func (r *RedisCache) Remove(key string) int

func (*RedisCache) Set

func (r *RedisCache) Set(key string, value interface{}, ttl time.Duration) error

func (*RedisCache) SetStruct

func (r *RedisCache) SetStruct(k string, d interface{}, ttl time.Duration) error

func (*RedisCache) SetTtl

func (r *RedisCache) SetTtl(key string, ttl time.Duration) bool

Jump to

Keyboard shortcuts

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