temp_map

1.0.1 • Public • Published

TempMap

npm version Build Status codecov dependencies Status PRs Welcome

TempMap is in-memory data structure with ttl. It has zero-dependencies.

Install

npm i temp_map

Usage example

    const { TempMap } = require('temp_map')
    const cache = new TempMap()
    const expireMs = 1000

    cache.set('key', 'value', expireMs)
    console.log(cache.get('key')) // value
    
    setTimeout(() => cache.get('key'), 2000) // undefined

Notes

This data structure on top of Node.js timers. Timers are crucial to Node.js.
Internally, any TCP I/O connection creates a timer so that we can time out of connections.
Similar to other hashed wheel timers, Node.js uses a hash table and a linked list to maintain the timers instances.

Readme

Keywords

none

Package Sidebar

Install

npm i temp_map

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

6.8 kB

Total Files

10

Last publish

Collaborators

  • you-think-you-are-special