Skip to content

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

License

Notifications You must be signed in to change notification settings

you-think-you-are-special/temp_map

Repository files navigation

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.

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published