simple-stash

1.2.1 • Public • Published

Build Status Coverage Status npm version

Simple Stash

Simple in-memory caching for Javascript.

Installation

$ npm install simple-stash --save

View on NPM

Usage

Get an item from memory

const cache = require('simple-stash');

const data = [
    {
        id: 'test-uuid-1',
        name: 'John Smith'
    },
    {
        id: 'test-uuid-2',
        name: 'Jane Miller'
    }
];

cache.set('users', data);

const customer = cache.get('users:id:test-uuid-1');

console.log(customer);

Logs:

{
    "id": "test-uuid-1",
    "name": "John Smith"
}

Get multiple items from memory

const cache = require('simple-stash');

const data = [
    {
        id: 'test-uuid-1',
        name: 'John Smith'
    },
    {
        id: 'test-uuid-2',
        name: 'John Smith'
    },
    {
        id: 'test-uuid-3',
        name: 'Jane Miller'
    }
];

cache.set('users', data);

const customers = cache.getAll('users:name:John Smith');

console.log(customers);

Logs:

[
    {
        "id": "test-uuid-1",
        "name": "John Smith"
    },
    {
        "id": "test-uuid-2",
        "name": "John Smith"
    }
]

Clear the cache

You can also remove all items from storage.

cache.clear();

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Readme

Keywords

none

Package Sidebar

Install

npm i simple-stash

Weekly Downloads

1

Version

1.2.1

License

MIT

Unpacked Size

11.3 kB

Total Files

8

Last publish

Collaborators

  • codyjdalton