1 Star 0 Fork 0

dengchengHu / LRUcache

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
README.md 869 Bytes
一键复制 编辑 原始数据 按行查看 历史
dengchengH 提交于 2019-07-16 15:46 . 文档说明进行了修改

LRUcache

介绍

一个通过 go 实现的 简单的 LRUcache 库

使用方法

go get gitee.com/dengchengH/LRUcache

具体功能实现

新建一个 LRUcache

func NewLRUcache(size int, onEvict EvictCallback) (*LRUcache, error)

通过 key 值获取 value 值

func Get(key interface{}) (interface{}, bool)

添加一个 value 值到 cache 中

func Add(key, value interface{}) bool

返回 cache 的长度

func Len() int

根据提供的 key 删除相应的元素

func Remove(key interface{}) bool 

删除最旧的元素

func RemoveOldest() (interface{}, interface{}, bool)

获取最旧的元素

func GetOldest() (interface{}, interface{}, bool)

获取当前 cache 中的列表

func KeyList() []interface{}

清空整个 cache

func Clear()
Go
1
https://gitee.com/dengchengH/LRUcache.git
git@gitee.com:dengchengH/LRUcache.git
dengchengH
LRUcache
LRUcache
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891