New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

basic-cache

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

basic-cache

The most basic memory caching module ever.

  • 0.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

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.

FAQs

Package last updated on 02 Sep 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc