/ live.thehmm.nl / back / node_modules / global-cache /

[ICO]NameLast modifiedSizeDescription
[PARENTDIR]Parent Directory  -  
[TXT]CHANGELOG.md8 years ago1.9K 
[   ]LICENSE10 years ago1.1K 
[   ]Makefile10 years ago3.7K 
[TXT]README.md10 years ago2.0Kd7c1522 post receive test [كارل مبارك]
[   ]index.js8 years ago2.1K 
[   ]package.json2 years ago3.1K 
[   ]test.js8 years ago3.9K 
README.md

global-cache Version Badge

Build Status dependency status dev dependency status License Downloads

npm badge

browser support

Sometimes you have to do horrible things, like use the global object to share a singleton. Abstract that away, with this!

This attaches a cache to the global object. It attempts to make it as undiscoverable as possible:

Keys are required to be strings or symbols.

Example

var cache = require('global-cache');
var assert = require('assert');

var value = {};
assert(cache.get(key) === undefined);
assert(cache.has(key) === false);

cache.set(key, value);
assert(cache.get(key) === value);
assert(cache.has(key) === true);

cache.delete(key);
assert(cache.get(key) === undefined);
assert(cache.has(key) === false);

Tests

Simply clone the repo, npm install, and run npm test

Apache/2.4.38 (Debian) Server at www.karls.computer Port 80