New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

github.com/fangxz/expired_map

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/fangxz/expired_map

  • v0.0.2
  • Source
  • Go
  • Socket score

Version published
Created
Source

ExpiredMap

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

key过期策略:

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

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

适用场景:

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

FAQs

Package last updated on 26 Jul 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc