npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

cacheman-promise

v1.6.0

Published

cacheman with a promise interface.

Readme

Cacheman-Promise

NPM version Downloads Build Status Dependency Status Coverage Status

NPM

Cacheman library with a promise interface.

Installation

$ npm install --save cacheman-promise

Usage

Cacheman-promise only support set, get, del, clear, pull and wrap promise interface.

Cacheman([name, [options]])

Please refer to Cacheman Options API

var Cacheman = require('cacheman-promise');

var options = {
  ttl: 90,
  engine: 'redis',
  port: 9999,
  host: '127.0.0.1'
};

var cache = new Cacheman('todo', options);
// or
var cache = new Cacheman(options);

cache.set(key, value, [ttl, [fn]])

Usage:

var key = 'foo';
var data = 'bar';

cache.set(key, {name: data})
  .then(function(val){
    // output "{name: 'bar'}"
    console.log(val);
  });

cache.get(key, fn)

You can pass array or string as key.

Usage:


cache.set('foo', 'bar');

cache.get('foo')
  .then(function(val){
    // output "bar"
    console.log(val);
  });

pass array as multiple keys

Usage:


cache.set('foo', 1);
cache.set('bar', 2);

cache.get(['foo', 'bar'])
  .then(function(result){
    // output {"foo": 1, "bar": 2}
    console.log(result);
  });

cache.pull(key, default)

If you need to retrieve an item from the cache and then delete it, you may use the pull method. Like the get method, null will be returned if the item does not exist in the cache.

cache.set('foo', 'bar');

cache.pull('foo')
  .then(function(result){
    // output 'bar'
    console.log(result);
  }).then(function() {
    return cache.get('foo');
  }).then(function(result) {
    // output 'null'
    console.log(result);
  });

You can pass default value as second paramaeter if the item doesn't exist in the cache.

// make sure `foo` cache doesn't exist.
cache.del('foo');

cache.pull('foo', 'bar')
  .then(function(result){
    // output 'bar'
    console.log(result);
  });

cache.del(key, [fn])

You can pass array or string as key.

Usage:

cache.del('foo')
  .then(function(){
    console.log('foo was deleted');
  });

or

cache.del(['foo', 'bar'])
  .then(function(){
    console.log('foo and bar was deleted');
  });

Clear some items with prefix name:

cache.clear('foo*')
  .then(function(){
    console.log('clear cache with `foo` prefix name like `foo1`, `foo2` etc.');
  });

cache.clear([fn])

Clear all cache as follwoing:

cache.clear()
  .then(function(){
    console.log('cache is now clear');
  });

cache.wrap(key, default, [ttl, [fn]])

Wraps a function in cache. I.e., the first time the function is run, its results are stored in cache so subsequent calls retrieve from cache instead of calling the function.

var key = 'foo';
var data = 'bar';

cache.wrap(key, data)
  .then(function(val) {

    // get foo key from cache
    return cache.get(key);
  }).then(function(val) {

    // output 'bar'
    console.log(val);
  });

Run tests

$ npm test