1.2.1 • Published 6 years ago

simple-stash v1.2.1

Weekly downloads
5
License
MIT
Repository
github
Last release
6 years ago

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.

1.2.1

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago