ttl-cache

1.0.2 • Public • Published

node-ttl-cache

Simple in-memory object cache with TTL based per-item expiry

Installation:

npm install ttl-cache

Usage:

var Cache = require('ttl-cache'),
    cache = new Cache();

old_value = cache.set(key, value); // Set a value (returns old)
new_value = cache.get(key); // Get a value
values = cache.mget(key1, key2); // Get multiple values at once
cache.del(key1, key2); // Delete one or more values at once
cache.ttl(key, 3); // Change the ttl of a value (in seconds)
cache.flush(); // Wipe the lot

Options:

var cache({
        ttl: 300,       // Number of seconds to keep entries
        interval: 60    // Cleaning interval
    });

License:

Project code is released under CC0 license:

CC0

/ttl-cache/

    Package Sidebar

    Install

    npm i ttl-cache

    Weekly Downloads

    151

    Version

    1.0.2

    License

    CC0

    Last publish

    Collaborators

    • norganna