Documentation ¶
Index ¶
- type CacheComponent
- func (comp *CacheComponent) Del(keys ...string) error
- func (comp *CacheComponent) Exists(key string) bool
- func (comp *CacheComponent) Flush() error
- func (comp *CacheComponent) Get(key string) interface{}
- func (comp *CacheComponent) Init(configI camBase.ComponentConfigInterface)
- func (comp *CacheComponent) Set(key string, value interface{}) error
- func (comp *CacheComponent) SetDuration(key string, value interface{}, duration time.Duration) error
- func (comp *CacheComponent) Start()
- func (comp *CacheComponent) Stop()
- type CacheComponentConfig
- type CacheInterface
- type FileCache
- func (cache *FileCache) Del(keys ...string) error
- func (cache *FileCache) Flush() error
- func (cache *FileCache) GC() error
- func (cache *FileCache) Get(key string) interface{}
- func (cache *FileCache) GetGCInterval() time.Duration
- func (cache *FileCache) Init() error
- func (cache *FileCache) Set(key string, value interface{}, duration time.Duration) error
- type FileCacheAo
- type RedisCache
- func (cache *RedisCache) Del(keys ...string) error
- func (cache *RedisCache) Flush() error
- func (cache *RedisCache) GC() error
- func (cache *RedisCache) Get(key string) interface{}
- func (cache *RedisCache) GetGCInterval() time.Duration
- func (cache *RedisCache) Init() error
- func (cache *RedisCache) Set(key string, value interface{}, duration time.Duration) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacheComponent ¶
type CacheComponent struct { component.Component camBase.CacheComponentInterface // contains filtered or unexported fields }
cache component
func (*CacheComponent) Exists ¶
func (comp *CacheComponent) Exists(key string) bool
whether the key exists
func (*CacheComponent) Get ¶
func (comp *CacheComponent) Get(key string) interface{}
get value by key
func (*CacheComponent) Init ¶
func (comp *CacheComponent) Init(configI camBase.ComponentConfigInterface)
init config
func (*CacheComponent) Set ¶
func (comp *CacheComponent) Set(key string, value interface{}) error
set cache
func (*CacheComponent) SetDuration ¶
func (comp *CacheComponent) SetDuration(key string, value interface{}, duration time.Duration) error
set cache with duration
type CacheComponentConfig ¶
type CacheComponentConfig struct { component.ComponentConfig Engine CacheInterface DefaultDuration time.Duration }
cache component config
type CacheInterface ¶
type CacheInterface interface { // init cache driver. connect server or create cache system Init() error // put cache Set(key string, value interface{}, duration time.Duration) error // get cache Get(key string) interface{} // delete cache Del(keys ...string) error // get GC interval GetGCInterval() time.Duration // garbage collection GC() error // clear all cache Flush() error }
cache driver interface
type FileCache ¶
type FileCache struct { CacheInterface DirDepth int // cache dir depth FilePath string // cache dir GcCheckNum int // number of times to check file whether GC GCInterval time.Duration // GC interval }
func NewFileCache ¶
func NewFileCache() *FileCache
func (*FileCache) GetGCInterval ¶
get GC interval
type FileCacheAo ¶
type FileCacheAo struct { Value interface{} `json:"v"` DeadTimestamp float64 `json:"dt"` // timestamp in seconds }
file cache application object
func NewFileCacheAo ¶
func NewFileCacheAo(value interface{}, duration time.Duration) *FileCacheAo
new object
func (*FileCacheAo) IsDeadNano ¶
func (ao *FileCacheAo) IsDeadNano() bool
is dead. Accurate to nanosecond
type RedisCache ¶
type RedisCache struct { CacheInterface Addr string Password string DB int // contains filtered or unexported fields }
redis cache engine
func (*RedisCache) Del ¶
func (cache *RedisCache) Del(keys ...string) error
delete value form engine
func (*RedisCache) GetGCInterval ¶
func (cache *RedisCache) GetGCInterval() time.Duration
get GC interval
Click to show internal directories.
Click to hide internal directories.