Nomnom Pumpernickle Muffins

    single-value-cache
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.4 • Public • Published

    single-value-cache

    npm version 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')

    Install

    npm i single-value-cache

    DownloadsWeekly Downloads

    0

    Version

    1.0.4

    License

    MIT

    Unpacked Size

    6.28 kB

    Total Files

    9

    Last publish

    Collaborators

    • kibertoad