Documentation ¶
Index ¶
- Constants
- type Cache
- type CacheModel
- type RedisManager
- func (r *RedisManager) Check(key interface{}) error
- func (r *RedisManager) Delete(key interface{}) error
- func (r *RedisManager) DeleteMore(key interface{}) error
- func (r *RedisManager) ExpireKey(key interface{}, seconds int64) bool
- func (r *RedisManager) Get(key interface{}) (CacheModel, error)
- func (r *RedisManager) NewCache() error
- func (r *RedisManager) Set(key interface{}, value CacheModel) error
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() 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 // expire key time ExpireKey(key interface{}, seconds int64) bool }
cache manager
type CacheModel ¶
type CacheModel struct { // seconds Time int64 `json:"time,omitempty"` // data Data interface{} `json:"data,omitempty"` }
data model
func (CacheModel) Struct ¶ added in v1.10.1
func (c CacheModel) Struct(v interface{}) error
Deprecated c.Data to v
func (CacheModel) Unmarshal ¶
func (c CacheModel) Unmarshal(v interface{}) error
Unmarshal support Struct/Array
type RedisManager ¶ added in v1.7.8
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) ExpireKey ¶ added in v1.20.0
func (r *RedisManager) ExpireKey(key interface{}, seconds int64) bool
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() 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
Click to show internal directories.
Click to hide internal directories.