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 🙏

© 2025 – Pkg Stats / Ryan Hefner

node-memory-cache

v0.0.5

Published

An in-memory cache implementation.

Readme

node-memory-cache

A simple in memory cache module for node.js

  • Key/Value store, except that for each key you can store multiple properties, like: key.property1 or key.property2.
  • Native support for counters.
  • You can set different expirations on properties, like: key.property1 expires every 1000ms, and key.property2 every 5000ms.

Installation

npm install node-memory-cache

Usage

var cache = require('node-memory-cache');

// Set an object property
cache.set("ObjectId", "ObjectProperty", "Value");

// Set an object property with a 3000ms expiration
cache.set("ObjectId", "ObjectPropertyWithExpiration", "Another Value", 3000);

// Get the object properties
cache.get("ObjectId", "ObjectProperty");
cache.get("ObjectId", "ObjectPropertyWithExpiration");

// Set a new property that is a counter, and increment it with +1
cache.increment("ObjectId", "CounterProperty", 1);

// Set a new property that is a counter, and increment it with +10, with a 5000ms expiration.
cache.increment("ObjectId", "CounterPropertyWithExpiration", 10, 5000);

// Decrementing a value, it is like incrementing it with a negative amount
cache.increment("ObjectId", "CounterProperty", -5);

// Expiration dates can be overwritten by specifying them again
cache.set("ObjectId", "ObjectPropertyWithExpiration", "Value", 3000);
cache.set("ObjectId", "ObjectPropertyWithExpiration", "Another Value", 5000); // Now the expiration has been updated to 5000ms

// The same for counters
cache.increment("ObjectId", "CounterPropertyWithExpiration", 1, 2000); // The counter has a 2000ms expiration

// The counter still keeps a 2000ms expiration
cache.increment("ObjectId", "CounterPropertyWithExpiration", 3); 
cache.increment("ObjectId", "CounterPropertyWithExpiration", 4);

// We update the expiration date to 5000ms while incrementing the value
cache.increment("ObjectId", "CounterPropertyWithExpiration", 1, 5000);

// To remove an expiration just set it to zero
cache.increment("ObjectId", "CounterPropertyWithExpiration", 1, 0); // We removed the expiration to this property

// Delete a property/counter
cache.delete("ObjectId", "ObjectProperty");

// Get all items stored
var data = cache.getAll();

// Initialize the cache with some predefined data: expected to be in the same format as the return value of getAll()
cache.populate(data);

Support

Open an issue on GitHub.