storage-ttl

localStorage objets and ttl manager Edit


Keywords
localstorage, ttl, object, json, storage, node
License
BSD-2-Clause
Install
npm install storage-ttl@1.0.2

Documentation

storage NPM version

Basic object store for javascript

Install with npm

npm i storage-ttl --save

Usage

var storage = require('storage-ttl');

.set

  • key {String}
  • value {*}
storage.set('foo', {bar: 'bar'})
storage.set('foo', 'value')

Assign value to key.

.setTTL

  • key {String}
  • value {*}
  • ttl {Number}: value in minutes
storage.setTTL('foo', {bar: 'bar'}, 1)
storage.setTTL('foo', 'value', 1)

Assign value to key with a ttl.

.get

  • key {String}
  • returns {*}: Returns the stored value of key
const value = storage.get('foo')

Get the stored value of key.

.remove

  • key {String}
storage.remove('foo')

Removes the stored value of key.

.count

const count = storage.count()

Gets the stored keys count.

.all

const items = storage.all()

Gets all the stored keys.

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue

Author

João Moura

License

Copyright (c) 2017 João Moura Released under the BSD 2-clause "Simplified" License