首页 > 编程语言 > 详细

双链表 哈希 go 实现lFU 缓存算法

时间:2021-03-14 10:15:29      阅读:17      评论:0      收藏:0      [点我收藏+]

什么是LFU

LFU
Least frequently used, 基于访问的频次和时间来淘汰数据。比如缓存满了,使用LFU算法,可以淘汰掉访问频次最少且访问时间靠后的元素。

leetcode也有相应的题目,只要实现Get, Put接口即可。

本文除了实现Get, Put, 还实现了GetIterator和GetAll接口,接口如下

func (lfu *LFUCache) Get(key interface{}) interface{}
func (lfu *LFUCache) Put(key interface{}, value interface{}) 
func (lfu *LFUCache) GetIterator() func() *dbNode
func (lfu *LFUCache) GetAll() []interface{} 

完整代码见github

双链表 哈希 go 实现lFU 缓存算法

原文:https://www.cnblogs.com/linyihai/p/14531183.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!