1.0.4 • Published 3 years ago

single-value-cache v1.0.4

Weekly downloads
7
License
MIT
Repository
github
Last release
3 years ago

single-value-cache

npm version npm.io Coverage Status

Simple, TTL-based Node.js cache for single values. Returns undefined if user attempts to retrieve expired value.

Usage

Setting new value

import { SingleValueCache } from 'single-value-cache'

const cache = new SingleValueCache(500) // TTL in msecs
cache.set('token')
const token = cache.get()
expect(token).toEqual('token')

Clearing cache

import { SingleValueCache } from 'single-value-cache'

const cache = new SingleValueCache(500) // TTL in msecs
cache.set('token')
cache.clear()
const token = cache.get()
expect(token).toBeUndefined()

Updating value

import { SingleValueCache } from 'single-value-cache'

const cache = new SingleValueCache(500) // TTL in msecs
cache.set('token')
cache.set('token2')
const token = cache.get()
expect(token).toEqual('token2')
1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago