Skip to content

norganna/node-ttl-cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.set(key, value, ttl); // Set a value, override default ttl
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

About

Simple object cache with ttl expiry.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published