Documentation ¶
Index ¶
- Constants
- func GenRandStr(n int) string
- type Cache
- func (lc *Cache) Delete(key string)
- func (lc *Cache) Get(key string) (value interface{}, ttl int64, exist bool)
- func (lc *Cache) GetLen() int64
- func (lc *Cache) GetRand(key string) string
- func (lc *Cache) Recycle()
- func (lc *Cache) Set(key string, value interface{}, ttlSecond int64)
- func (lc *Cache) SetMaxRecords(limit int64)
- func (lc *Cache) SetRand(key string, ttlSecond int64) string
Constants ¶
View Source
const ( MaxRecords = 1000000 MinRecords = 10000 MaxTTLSecs = 7200 RecycleIntervalSecs = 5 RecycleOverLimitRatio = 0.15 )
Variables ¶
This section is empty.
Functions ¶
func GenRandStr ¶ added in v0.1.3
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
func (*Cache) Set ¶
if ttl < 0 just return and nothing changes ttl is set to MaxTTLSecs if ttl > MaxTTLSecs if record exist , "0" ttl changes nothing if record not exist, "0" ttl is equal to "30" seconds
func (*Cache) SetMaxRecords ¶ added in v0.1.3
RecycleOverLimitRatio of records will be recycled if the number of total keys exceeds this limit
Click to show internal directories.
Click to hide internal directories.