Documentation ¶
Overview ¶
Package gcache provides high performance and concurrent-safe in-memory cache for process.
缓存模块, 并发安全的单进程高速缓存.
Index ¶
- func BatchRemove(keys []interface{})
- func BatchSet(data map[interface{}]interface{}, expire int)
- func Contains(key interface{}) bool
- func Data() map[interface{}]interface{}
- func Get(key interface{}) interface{}
- func GetOrSet(key interface{}, value interface{}, expire int) interface{}
- func GetOrSetFunc(key interface{}, f func() interface{}, expire int) interface{}
- func GetOrSetFuncLock(key interface{}, f func() interface{}, expire int) interface{}
- func KeyStrings() []string
- func Keys() []interface{}
- func Remove(key interface{}) interface{}
- func Set(key interface{}, value interface{}, expire int)
- func SetIfNotExist(key interface{}, value interface{}, expire int) bool
- func Size() int
- func Values() []interface{}
- type Cache
- func (c Cache) BatchRemove(keys []interface{})
- func (c Cache) BatchSet(data map[interface{}]interface{}, expire int)
- func (c *Cache) Clear()
- func (c Cache) Close()
- func (c Cache) Contains(key interface{}) bool
- func (c Cache) Data() map[interface{}]interface{}
- func (c Cache) Get(key interface{}) interface{}
- func (c Cache) GetOrSet(key interface{}, value interface{}, expire int) interface{}
- func (c Cache) GetOrSetFunc(key interface{}, f func() interface{}, expire int) interface{}
- func (c Cache) GetOrSetFuncLock(key interface{}, f func() interface{}, expire int) interface{}
- func (c Cache) KeyStrings() []string
- func (c Cache) Keys() []interface{}
- func (c Cache) Remove(key interface{}) (value interface{})
- func (c Cache) Set(key interface{}, value interface{}, expire int)
- func (c Cache) SetIfNotExist(key interface{}, value interface{}, expire int) bool
- func (c Cache) Size() (size int)
- func (c Cache) Values() []interface{}
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BatchSet ¶ added in v1.5.0
func BatchSet(data map[interface{}]interface{}, expire int)
(使用全局KV缓存对象)批量设置kv缓存键值对,过期时间单位为**毫秒**
func GetOrSet ¶
func GetOrSet(key interface{}, value interface{}, expire int) interface{}
当键名存在时返回其键值,否则写入指定的键值
func GetOrSetFunc ¶
func GetOrSetFunc(key interface{}, f func() interface{}, expire int) interface{}
当键名存在时返回其键值,否则写入指定的键值,键值由指定的函数生成
func GetOrSetFuncLock ¶
func GetOrSetFuncLock(key interface{}, f func() interface{}, expire int) interface{}
与GetOrSetFunc不同的是,f是在写锁机制内执行
func Set ¶
func Set(key interface{}, value interface{}, expire int)
(使用全局KV缓存对象)设置kv缓存键值对,过期时间单位为**毫秒**
func SetIfNotExist ¶
当键名不存在时写入,并返回true;否则返回false。 常用来做对并发性要求不高的内存锁。
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
缓存对象。 底层只有一个缓存对象,如果需要提高并发性能,可新增缓存对象无锁哈希表,用键名做固定分区。
func (Cache) BatchRemove ¶ added in v1.5.0
func (c Cache) BatchRemove(keys []interface{})
批量删除键值对,并返回被删除的键值对数据
func (Cache) BatchSet ¶ added in v1.5.0
func (c Cache) BatchSet(data map[interface{}]interface{}, expire int)
批量设置
func (Cache) Contains ¶
func (c Cache) Contains(key interface{}) bool
是否存在指定的键名,true表示存在,false表示不存在。
func (Cache) GetOrSet ¶
func (c Cache) GetOrSet(key interface{}, value interface{}, expire int) interface{}
当键名存在时返回其键值,否则写入指定的键值
func (Cache) GetOrSetFunc ¶
func (c Cache) GetOrSetFunc(key interface{}, f func() interface{}, expire int) interface{}
当键名存在时返回其键值,否则写入指定的键值,键值由指定的函数生成
func (Cache) GetOrSetFuncLock ¶
func (c Cache) GetOrSetFuncLock(key interface{}, f func() interface{}, expire int) interface{}
与GetOrSetFunc不同的是,f是在写锁机制内执行
func (Cache) Set ¶
func (c Cache) Set(key interface{}, value interface{}, expire int)
设置kv缓存键值对,过期时间单位为毫秒,expire<=0表示不过期
func (Cache) SetIfNotExist ¶
当键名不存在时写入,并返回true;否则返回false。
Click to show internal directories.
Click to hide internal directories.