![]() | Name | Last modified | Size | Description |
---|---|---|---|---|
![]() | Parent Directory | - | ||
![]() | CHANGELOG.md | 8 years ago | 1.9K | |
![]() | LICENSE | 10 years ago | 1.1K | |
![]() | Makefile | 10 years ago | 3.7K | |
![]() | README.md | 10 years ago | 2.0K | d7c1522 post receive test [كارل مبارك] |
![]() | index.js | 8 years ago | 2.1K | |
![]() | package.json | 2 years ago | 3.1K | |
![]() | test.js | 8 years ago | 3.9K |
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.
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);
Simply clone the repo, npm install
, and run npm test