Numbers Produce Meaning

    tiny-ttl-cache

    1.0.1 • Public • Published

    NPM version Build Status Dependency Status

    Simple TTL cache. put and get.

    Suitable for use in browsers and Node.js.

    Install

    $ npm install --save tiny-ttl-cache

    Usage

    var TTLCache = require('tiny-ttl-cache');
     
    var maxSize = 100;
    var timeToLive = 10 * 1000; // 10s in ms
     
    var cache = new TTLCache(maxSize, timeToLive);
    cache.put('key', 'value');
    cache.get('key'); // returns 'value'
     
    // 10 seconds later
    cache.get('key'); // returns null
     
    cache.flush(); // Empties the cache

    TTL Eviction Policy

    Once the cache reaches its maximum size, the item with the shortest TTL is removed.

    Development

    npm install
    npm test

    License

    MIT © Andy Hume

    Install

    npm i tiny-ttl-cache

    DownloadsWeekly Downloads

    0

    Version

    1.0.1

    License

    MIT

    Last publish

    Collaborators

    • ahume