3.0.0 • Public • Published

logo-stash-it-color-dark 2x

stash-it is a caching mechanism based on plugins.

It's core concept is to stay simple, small and easily extendable using plugins.

Plugins allow you to:
  • write handlers for hook'able methods
  • extend API of cache object

stash-it can be used in various environments (client, server or native), depending on what adapter you use.

It's very small ~2kB (including memory adapter, minified + gzipped) with no dependencies whatsoever.

build status Coverage Status

Why stash-it?

At one time, I was looking for a cache mechanism for node, that would allow me to add tags to stored items. I found some solutions. But when I dug deeper I started to find various modules that were either too big, had too few / many methods, were hard to use or not maintained for a very long time.

Then I thought - if there isn't anything close to what I am looking for, why not create something of my own.

That's how stash-it came to be.


npm install stash-it --save

stash-it is just a core module, which provides means to create cache or register plugins. It doesn't come with any adapter or plugin out of the box. Therefore you will either need to provide an adapter or install one:

npm install stash-it-adapter-memory --save

Now, you have everything for the most basic usage of stash-it.

Let's give it a try

(mind that I am using ES6 syntax)

import { createCache } from 'stash-it';
import createMemoryAdapter from 'stash-it-adapter-memory';

// First, we need to create an adapter
const adapter = createMemoryAdapter();

// Now, let's create cache instance
const cache = createCache(adapter);

// Cool! Now time for some actions
cache.setItem('key', 'some very often fetched value I need to store');
cache.hasItem('key'); // true

const item = cache.getItem('key');

console.log(item.value); // some very often fetched value I need to store

cache.removeItem('key'); // true
cache.hasItem('key'); // false

And that's pretty much it.


stash-it is build in ES6 for modern environments. If you need to run it in older ones, you will have to transpile it. See .babelrc file for more details.


(for v2 head over here.)






Package Sidebar


npm i stash-it

Weekly Downloads






Unpacked Size

16.6 kB

Total Files


Last publish


  • jaceks