{"_id":"ya-cache","_rev":"332470","name":"ya-cache","description":"Yet another cache","dist-tags":{"latest":"1.0.1"},"maintainers":[{"name":"spalger","email":"email@spalger.com"}],"time":{"modified":"2021-06-07T02:48:37.000Z","created":"2015-06-14T10:59:20.622Z","1.0.1":"2015-06-15T07:42:52.084Z","1.0.0":"2015-06-15T07:31:12.512Z","1.0.0-alpha.2":"2015-06-15T05:52:40.464Z","1.0.0-alpha.1":"2015-06-14T21:59:03.475Z","1.0.0-alpha":"2015-06-14T10:59:20.622Z"},"users":{},"author":{"name":"Spencer Alger","email":"email@spalger.com"},"repository":{"type":"git","url":"git+https://github.com/spalger/ya-cache.git"},"versions":{"1.0.1":{"name":"ya-cache","version":"1.0.1","description":"Yet another cache","main":"lib/Cache.js","scripts":{"test":"npm run compile && mocha lib/**/__tests__/**/*.js","compile":"rm -rf lib && babel --optional runtime src/ -d lib/","prepublish":"npm run compile"},"keywords":["cache","fs","lock"],"author":{"name":"Spencer Alger","email":"email@spalger.com"},"license":"MIT","dependencies":{"babel-runtime":"^5.5.8","debug":"^2.2.0","lockfile":"^1.0.1","mkdirp":"^0.5.1","promify":"^1.0.1"},"devDependencies":{"babel":"^5.5.7","chai":"^3.0.0","chai-as-promised":"^5.1.0","mocha":"^2.2.5","sinon":"^1.15.3"},"directories":{"test":"test"},"repository":{"type":"git","url":"git+https://github.com/spalger/ya-cache.git"},"bugs":{"url":"https://github.com/spalger/ya-cache/issues"},"homepage":"https://github.com/spalger/ya-cache#readme","gitHead":"5d6d9dfe17aad1986c5755c3f5ae9ce51adba38d","_id":"ya-cache@1.0.1","_shasum":"e630a35b4a2adea35dea7d7d1efff68ee50f2b34","_from":".","_npmVersion":"2.11.1","_nodeVersion":"2.3.0","_npmUser":{"name":"spalger","email":"email@spalger.com"},"dist":{"shasum":"e630a35b4a2adea35dea7d7d1efff68ee50f2b34","size":4980,"noattachment":false,"key":"/ya-cache/-/ya-cache-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/ya-cache/download/ya-cache-1.0.1.tgz"},"maintainers":[{"name":"spalger","email":"email@spalger.com"}],"publish_time":1434354172084,"_cnpm_publish_time":1434354172084,"_hasShrinkwrap":false},"1.0.0":{"name":"ya-cache","version":"1.0.0","description":"Yet another cache","main":"lib/Cache.js","scripts":{"test":"npm run compile && mocha lib/**/__tests__/**/*.js","compile":"rm -rf lib && babel --optional runtime src/ -d lib/","prepublish":"npm run compile"},"keywords":["cache","fs","lock"],"author":{"name":"Spencer Alger","email":"email@spalger.com"},"license":"MIT","dependencies":{"babel-runtime":"^5.5.8","debug":"^2.2.0","lockfile":"^1.0.1","mkdirp":"^0.5.1","promify":"^1.0.1"},"devDependencies":{"babel":"^5.5.7","chai":"^3.0.0","chai-as-promised":"^5.1.0","mocha":"^2.2.5","sinon":"^1.15.3"},"gitHead":"4e73b306eda389fd0aeea9a7f4f1481848354b4e","_id":"ya-cache@1.0.0","_shasum":"2704f455928b041a181bdcfb350e91f506337cd2","_from":".","_npmVersion":"2.11.1","_nodeVersion":"2.3.0","_npmUser":{"name":"spalger","email":"email@spalger.com"},"dist":{"shasum":"2704f455928b041a181bdcfb350e91f506337cd2","size":4896,"noattachment":false,"key":"/ya-cache/-/ya-cache-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/ya-cache/download/ya-cache-1.0.0.tgz"},"maintainers":[{"name":"spalger","email":"email@spalger.com"}],"directories":{},"publish_time":1434353472512,"_cnpm_publish_time":1434353472512,"_hasShrinkwrap":false},"1.0.0-alpha.2":{"name":"ya-cache","version":"1.0.0-alpha.2","description":"Yet another cache","main":"lib/Cache.js","scripts":{"test":"mocha -r babel/register -r test/support.js src/**/__tests__/**/*.js","compile":"rm -rf lib && babel src/ -d lib/ --ignore './__tests__/*'","prepublish":"npm run compile"},"keywords":["cache","fs","lock"],"author":{"name":"Spencer Alger","email":"email@spalger.com"},"license":"MIT","dependencies":{"debug":"^2.2.0","lockfile":"^1.0.1","mkdirp":"^0.5.1","promify":"^1.0.1"},"devDependencies":{"babel":"^5.5.7","chai":"^3.0.0","chai-as-promised":"^5.1.0","mocha":"^2.2.5","sinon":"^1.15.3"},"gitHead":"ee27ffaf19227cf8a7159e364d9666ad00a6d8a2","_id":"ya-cache@1.0.0-alpha.2","_shasum":"1a95df27112cd62b3bc18b1b281e4b4171c46687","_from":".","_npmVersion":"2.11.1","_nodeVersion":"2.3.0","_npmUser":{"name":"spalger","email":"email@spalger.com"},"dist":{"shasum":"1a95df27112cd62b3bc18b1b281e4b4171c46687","size":5266,"noattachment":false,"key":"/ya-cache/-/ya-cache-1.0.0-alpha.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/ya-cache/download/ya-cache-1.0.0-alpha.2.tgz"},"maintainers":[{"name":"spalger","email":"email@spalger.com"}],"directories":{},"publish_time":1434347560464,"_cnpm_publish_time":1434347560464,"_hasShrinkwrap":false},"1.0.0-alpha.1":{"name":"ya-cache","version":"1.0.0-alpha.1","description":"Yet another cache","main":"lib/Cache.js","scripts":{"test":"mocha -r babel/register -r test/support.js src/**/__tests__/**/*.js","compile":"rm -rf lib && babel src/ -d lib/ --ignore './__tests__/*'","prepublish":"npm run compile"},"keywords":["cache","fs","lock"],"author":{"name":"Spencer Alger","email":"email@spalger.com"},"license":"MIT","dependencies":{"debug":"^2.2.0","lockfile":"^1.0.1","lodash.clone":"^3.0.2","mkdirp":"^0.5.1","promify":"^1.0.1"},"devDependencies":{"babel":"^5.5.7","chai":"^3.0.0","chai-as-promised":"^5.1.0","mocha":"^2.2.5","sinon":"^1.15.3"},"gitHead":"94251d4ba9dede840978ad92ae09fe99768a032a","_id":"ya-cache@1.0.0-alpha.1","_shasum":"3aaeb583ea477d324d7cc92ff92d46493cee11ce","_from":".","_npmVersion":"2.11.1","_nodeVersion":"2.3.0","_npmUser":{"name":"spalger","email":"email@spalger.com"},"dist":{"shasum":"3aaeb583ea477d324d7cc92ff92d46493cee11ce","size":4951,"noattachment":false,"key":"/ya-cache/-/ya-cache-1.0.0-alpha.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/ya-cache/download/ya-cache-1.0.0-alpha.1.tgz"},"maintainers":[{"name":"spalger","email":"email@spalger.com"}],"directories":{},"publish_time":1434319143475,"_cnpm_publish_time":1434319143475,"_hasShrinkwrap":false},"1.0.0-alpha":{"name":"ya-cache","version":"1.0.0-alpha","description":"Yet another cache","main":"lib/Cache.js","scripts":{"test":"mocha -r babel/register -r test/support.js src/**/__tests__/**/*.js","compile":"rm -rf lib && babel src/ -d lib/ --ignore './__tests__/*'","prepublish":"npm run compile"},"keywords":["cache","fs","lock"],"author":{"name":"Spencer Alger","email":"email@spalger.com"},"license":"MIT","dependencies":{"debug":"^2.2.0","lockfile":"^1.0.1","mkdirp":"^0.5.1","promify":"^1.0.1"},"devDependencies":{"babel":"^5.5.7","chai":"^3.0.0","chai-as-promised":"^5.1.0","mocha":"^2.2.5","sinon":"^1.15.3"},"gitHead":"8b312aa5efd5cce683a3c47a8444221f7a244575","_id":"ya-cache@1.0.0-alpha","_shasum":"6e0c96f5913b876008860d1f77ff630b47158738","_from":".","_npmVersion":"2.11.1","_nodeVersion":"2.3.0","_npmUser":{"name":"spalger","email":"email@spalger.com"},"dist":{"shasum":"6e0c96f5913b876008860d1f77ff630b47158738","size":4852,"noattachment":false,"key":"/ya-cache/-/ya-cache-1.0.0-alpha.tgz","tarball":"http://registry.cnpm.dingdandao.com/ya-cache/download/ya-cache-1.0.0-alpha.tgz"},"maintainers":[{"name":"spalger","email":"email@spalger.com"}],"directories":{},"publish_time":1434279560622,"_cnpm_publish_time":1434279560622,"_hasShrinkwrap":false}},"readme":"# yet another cache\n\nWhy the heck does the world need another caching module? Well, it probably doesn't but while working on [http-asset](http://github.com/spalger/http-asset) part of me was feeling crazy, part of me was feeling ambitious, and the rest of me was too lazy to sift through all the caching modules on NPM to find the one that best fit the bill.\n\nSo, I offer you ya-cache.\n\n## features\n\n - super simple api\n - file system backed\n - cache is just JSON in a file\n - file system locking ¯\\\\&#95;(ツ)&#95;/¯\n\n## example\n\n```js\nlet Cache = require('ya-cache')\nlet thingCache = new Cache(join(__dirname, '__cache__'))\n\nconst HOUR = 1000 * 60 * 60\n\nlet [expires, thing] = thingCache.gets('expire', 'thing')\nif (expires && expires < Date.now()) {\n  thing = await calculateComplexThingy()\n  await thingCache.sets({\n    expire: Date.now() + 24 * HOUR\n    thing: thing\n  })\n}\n\ndoSomethingWithThing(thing)\n\n```\n\n## api\n\n---\n#### `new Cache(path, lockFileOptions = {})`\n\nConstructs a cache object, provides the api to each cache\n\n\n---\n#### `cache.get([key]) -> Promise`\n\nGet the value of a key, returns a promise. If the key argument is undefined then all keys and their values are returned in an object.\n\n```js\ncache.get('key').then(function (val) {\n  console.log('value for key is', val)\n})\n```\n\n---\n#### `cache.set(key, val) -> Promise`\n\nSet the value of a key, returns a promise.\n\n```js\ncache.set('key', 'value').then(function () {\n  console.log('value for %s is now set to %s', 'key', 'value')\n})\n```\n\n---\n#### `cache.gets(...keys) -> Promise`\n\nGet one or more keys, returns a promise that resolves to an array of values.\n\n```js\ncache.gets('key1', 'key2', 'key3').then(function (vals) {\n  vals.forEach(function (val, i) {\n    console.log('key%i has value %s', i + 1, val)\n  })\n})\n```\n\n---\n#### `cache.sets({ key: value ... }) -> Promise`\n\nSet one of more keys, returns a promise that resolves to an object of the saved values.\n\n```js\ncache.sets({\n  key1: 'foo'\n  key2: 'bar'\n  key3: 'baz'\n}).then(function (vals) {\n  console.log('saved vals', vals)\n})\n```\n\n---\n#### `cache.clear([key]) -> Promise`\n\nClear a key in the cache. If the key is undefined then all keys are cleared\n\n```js\ncache.set('foo', 'bar')\ncache.clear('foo')\ncache.get('foo').then(function (val) {\n  console.log('foo equals \"%s\"', val) // foo equals \"undefined\"\n})\n```","_attachments":{},"homepage":"https://github.com/spalger/ya-cache#readme","bugs":{"url":"https://github.com/spalger/ya-cache/issues"},"license":"MIT"}