Documentation ¶
Index ¶
- func Register(name string, adapter Adapter) error
- type Adapter
- type Cache
- type FileCache
- func (fc *FileCache) ClearAll() error
- func (fc *FileCache) Delete(key string) error
- func (fc *FileCache) Exists(key string) bool
- func (fc *FileCache) Get(key string) interface{}
- func (fc *FileCache) GetMulti(keys []string) []interface{}
- func (fc *FileCache) Init(config string) error
- func (fc *FileCache) Put(key string, value interface{}, timeout time.Duration) error
- type FileCacheItem
- type MemoryCache
- func (mc *MemoryCache) ClearAll() error
- func (mc *MemoryCache) Delete(key string) error
- func (mc *MemoryCache) Exists(key string) bool
- func (mc *MemoryCache) Get(key string) interface{}
- func (mc *MemoryCache) GetMulti(keys []string) []interface{}
- func (mc *MemoryCache) Init(config string) error
- func (mc *MemoryCache) Put(key string, value interface{}, timeout time.Duration) error
- type MemoryCacheItem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cache ¶
type Cache interface { // Init initialize the cache adapter with provided config string. Init(string) error // Get cached value by key. Get(string) interface{} // GetMulti values of Get. GetMulti([]string) []interface{} // Put sets the cache value with key and timeout. Put(string, interface{}, time.Duration) error // Delete cached value by key. Delete(string) error // Exists check if cached value exists. Exists(string) bool // ClearAll removes all cached values. ClearAll() error }
Cache contains the base cache adapter.
type FileCache ¶
FileCache is the file cache adapter.
type FileCacheItem ¶
FileCacheItem contains the cached data and expire time.
type MemoryCache ¶
type MemoryCache struct { sync.RWMutex Every int // run an expiration check Every clock time // contains filtered or unexported fields }
MemoryCache is memory cache adapter.
func (*MemoryCache) ClearAll ¶
func (mc *MemoryCache) ClearAll() error
ClearAll removes all cached values.
func (*MemoryCache) Delete ¶
func (mc *MemoryCache) Delete(key string) error
Delete cached value by key.
func (*MemoryCache) Exists ¶
func (mc *MemoryCache) Exists(key string) bool
Exists check if cached value exists.
func (*MemoryCache) Get ¶
func (mc *MemoryCache) Get(key string) interface{}
Get cached value by key.
func (*MemoryCache) GetMulti ¶
func (mc *MemoryCache) GetMulti(keys []string) []interface{}
GetMulti values of Get.
func (*MemoryCache) Init ¶
func (mc *MemoryCache) Init(config string) error
Init initialize the cache adapter with provided config string.
type MemoryCacheItem ¶
MemoryCacheItem contains the cached data and expire time.
Click to show internal directories.
Click to hide internal directories.