Documentation
¶
Index ¶
- Constants
- type Cache
- type CacheModel
- type Redis
- func (r *Redis) Check(key any) error
- func (r *Redis) Delete(key any) error
- func (r *Redis) DeleteMore(key any) error
- func (r *Redis) ExpireKey(key any, seconds int64) bool
- func (r *Redis) Get(key any) (CacheModel, error)
- func (r *Redis) Init() error
- func (r *Redis) Set(key any, 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 init cache
Init() error
// Set value
// if time != 0 set it
Set(key any, value CacheModel) error
// Get value
Get(key any) (CacheModel, error)
// Delete value
Delete(key any) error
// DeleteMore more del
// key will become *key*
DeleteMore(key any) error
// Check value
// flush the time
Check(key any) error
// ExpireKey expire key time
ExpireKey(key any, seconds int64) bool
}
Cache manager
type CacheModel ¶
type CacheModel struct {
// seconds
Time int64 `json:"time,omitempty"`
// data
Data any `json:"data,omitempty"`
}
CacheModel data model
func (CacheModel) Unmarshal ¶
func (c CacheModel) Unmarshal(v any) error
Unmarshal support Struct/Array c.Data to v
type Redis ¶
type Redis struct {
// contains filtered or unexported fields
}
Redis impl cache manager redis cache interface key, interface value
func (*Redis) DeleteMore ¶
Click to show internal directories.
Click to hide internal directories.