zoukankan      html  css  js  c++  java
  • 双链表 哈希 go 实现lFU 缓存算法

    什么是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

  • 相关阅读:
    npm
    模块化开发
    Html input 标签
    H5 移动端布局
    Mysql指令
    php面向对象
    git指令
    css3 属性
    如何渲染数据
    angular 服务
  • 原文地址:https://www.cnblogs.com/linyihai/p/14531183.html
Copyright © 2011-2022 走看看