Documentation
¶
Index ¶
Constants ¶
View Source
const (
PolicyTypeLRU = "lru"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface {
// Get a key and return the value and if the key exists
Get(key string) (interface{}, bool)
// Set a key-value with default seconds to live
Set(key string, value interface{})
// SetWithExpire set a key-value with seconds to live
SetWithExpire(key string, value interface{}, ttl int64)
// Del delete key
Del(key string)
// Len return count of keys in cache
Len() int
// Flush clear all keys in chache, should do this when set and del is stop
Flush()
// Stop the cacheProcess by close stopChan
Stop()
// Statistic return cache Statistic {"hit":1, "miss":1, "hitRate":50.0}
Statistic() map[string]interface{}
}
func NewLocalCache ¶
NewLocalCache return Cache obj with options
type Option ¶
type Option func(*localCache)
func WithGlobalTTL ¶
WithGlobalTTL set all keys default expire time of seconds
func WithPolicy ¶
WithPolicy set the elimination policy of keys
func WithShardCount ¶
WithShardCount shardCnt must be a power of 2
func WithStatist ¶
WithStatist set whether need to caculate the cache`s statist, default false.
not need may led performance a very little better ^-^
Directories
¶
| Path | Synopsis |
|---|---|
|
datastruct
|
|
|
list
Package list copy from datastruct.list what is more: 1、add a func NewElement() to support get a single Element whithout set prev and next and list 2、add a func PushElementFront() to insert the single element to first of the list which created by call NewElement()
|
Package list copy from datastruct.list what is more: 1、add a func NewElement() to support get a single Element whithout set prev and next and list 2、add a func PushElementFront() to insert the single element to first of the list which created by call NewElement() |
Click to show internal directories.
Click to hide internal directories.