package
Version:
v0.0.0-...-9c21ab8
Opens a new window with list of versions in this module.
Published: Dec 24, 2021
License: Apache-2.0
Opens a new window with license information.
Imports: 3
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
¶
func NewLRUCache(capacity int) *LRU
maxSize: 缓存的最大数量
func (lru *LRU) Set(key string, value interface{})
func NewTTLCache(aliveSeconds int64, capacity int) *TTL
aliveSeconds: 缓存有效期,capacity: 缓存容量,注意合理估计capacity为未过期元素的最大数量
func (ttl *TTL) Set(key string, value interface{})
当缓存容量超出指定值时,会主动扫描一遍过期键
但是这并不能保证缓存容量减少到指定范围之内
Source Files
¶
Click to show internal directories.
Click to hide internal directories.