basic-cache

0.0.4 • Public • Published

basic-cache

NPM

The best node caching module ever.

Getting Started

Install the module with: npm install basic-cache

var cache = require('basic-cache');

Methods

set(key, value, time)

Sets a key to a value and have it expire in time milliseconds.

cache.set('company', 'MadGlory', 2000);

get(key)

Gets the value of key.

var company = cache.get('company');

reset(key[, time])

Resets the expiration time of the key. You can optionally set a new time.

cache.reset('company'); // Resets to current time + original 2000
 
cache.reset('company', 1000); // Resets to current time + 1000

clear(key)

Removes the key from the cache.

cache.clear('company');

clearAll()

Removes ALL the keys from the cache.

cache.clearAll();

clean()

If for some reason a key's time expired, but it still exists in the cache running this method will clear all of those keys.

cache.clean();

keys()

Returns all the names of the keys in the cache as an array.

var keys = cache.keys();

size()

Returns the number of keys that are currently in the cache.

var size = cache.size();

Namespacing

var cache = require('basic-cache');
 
cache.set('NAMESPACE1:company', 'MadGlory');
cache.set('NAMESPACE2:company', 'Company 2');

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

License

Copyright (c) 2013 MadGlory. Licensed under the MIT license.

Readme

Keywords

none

Package Sidebar

Install

npm i basic-cache

Weekly Downloads

0

Version

0.0.4

License

none

Last publish

Collaborators

  • kixxauth
  • blainsmith