cache

package
v1.8.11 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CacheSecond = 1
	CacheMinute = 60
	CacheHour   = 60 * CacheMinute
	CacheDay    = 24 * CacheHour
	CacheWeek   = 7 * CacheDay
)

time for cache unit unit: second

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	// init cache
	NewCache(params ...interface{}) error
	// operate method
	// set value
	// if time != 0 set it
	Set(key interface{}, value CacheModel) error
	// get value
	Get(key interface{}) (CacheModel, error)
	// delete value
	Delete(key interface{}) error
	// more del
	// key will become *key*
	DeleteMore(key interface{}) error
	// check value
	// flush the time
	Check(key interface{}) error
}

cache manager

func NewCache

func NewCache(params ...interface{}) (cache Cache)

cache sugar the first param is Cache the second param is confiDir

type CacheModel

type CacheModel struct {
	// seconds
	Time int64 `json:"time"`
	// data
	Data interface{} `json:"data"`
}

data model

type RedisManager added in v1.7.8

type RedisManager struct {
	// do nothing else
	Rc *redis2.ConnPool
}

impl cache manager redis cache interface key, interface value

func (*RedisManager) Check added in v1.7.8

func (r *RedisManager) Check(key interface{}) error

func (*RedisManager) Delete added in v1.7.8

func (r *RedisManager) Delete(key interface{}) error

func (*RedisManager) DeleteMore added in v1.7.8

func (r *RedisManager) DeleteMore(key interface{}) error

func (*RedisManager) Get added in v1.7.8

func (r *RedisManager) Get(key interface{}) (CacheModel, error)

func (*RedisManager) NewCache added in v1.7.8

func (r *RedisManager) NewCache(params ...interface{}) error

new cache by redis other cache maybe like this

func (*RedisManager) Set added in v1.7.8

func (r *RedisManager) Set(key interface{}, value CacheModel) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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