Giter VIP home page Giter VIP logo

expired_map's Introduction

ExpiredMap

golang写的带有超时性质的map,可以给key设置存活时间,超期就会自动删除。 时间精度:秒级

key过期策略:

采用主动删除+被动删除的策略。

  • 每隔一秒删一次过期的key。
  • 用户访问该key时,判断是否过期,过期则删除。

适用场景:

  • 服务local cache,服务local cache会比使用redis缓存更为快速,有过期机制不会使内存持续增长。
  • 数据定期刷新,如每隔x分钟刷新一次榜单的逻辑,可以设置key过期时间为x分钟,每次Get判断有缓存,则用这些数据;如果没有缓存,则去db加载,set到缓存并设置过期时间。

expired_map's People

Contributors

lyl41 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.