Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cached

Package Overview
Dependencies
Maintainers
3
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cached - npm Package Compare versions

Comparing version 4.3.2 to 5.0.0

19

CHANGELOG.md

@@ -0,1 +1,20 @@

### 5.0.0
#### Breaking Changes
drops support for Node 6, which is a current LTS release.
*See: [`f4ba4c9`](https://github.com/groupon/node-cached/commit/f4ba4c988b5d5db0cf07edfe9f0013d5fada075f)*
#### Commits
* feat: drop node4 support - **[@aaarichter](https://github.com/aaarichter)** [#39](https://github.com/groupon/node-cached/pull/39)
- [`29b26fa`](https://github.com/groupon/node-cached/commit/29b26fa240033cd7b5409407ea42b375a29c4c33) **feat:** drop node4 support
- [`23dcc6a`](https://github.com/groupon/node-cached/commit/23dcc6aa409f82be5485f3041948a9cdd1c1755e) **chore:** feedback addressed
* Drop Node 6 support, and Babel as a result - **[@markowsiak](https://github.com/markowsiak)** [#40](https://github.com/groupon/node-cached/pull/40)
- [`2339fd1`](https://github.com/groupon/node-cached/commit/2339fd1d2064e6bab3f21fce0ca68af3916be129) **chore:** npm audit, drop babel
- [`f4ba4c9`](https://github.com/groupon/node-cached/commit/f4ba4c988b5d5db0cf07edfe9f0013d5fada075f) **chore:** drop support for node 6, keep async/await in test
- [`fe943d8`](https://github.com/groupon/node-cached/commit/fe943d8b7b34c7d4439e674cacc675699e3ba98e) **chore:** use npm 6 in travis
### 4.3.2

@@ -2,0 +21,0 @@

6

lib/backend.js

@@ -35,3 +35,3 @@ /*

const typeMap = Object.create(null);
const typeMap = new Map();

@@ -50,3 +50,3 @@ function isBackend(object) {

const type = options.type || 'noop';
const BackendClass = typeMap[type];
const BackendClass = typeMap.get(type);
if (!BackendClass) {

@@ -59,3 +59,3 @@ throw new Error(`${type} is not a supported cache backend type`);

function addType(type, BackendClass) {
typeMap[type] = BackendClass;
typeMap.set(type, BackendClass);
return BackendClass;

@@ -62,0 +62,0 @@ }

@@ -36,5 +36,6 @@ /*

const promisify = require('bluebird').promisify;
const _ = require('lodash');
const Memcached = require('memcached');
const noop = () => undefined;
function createClient(options) {

@@ -67,7 +68,8 @@ if (options.client) {

MemcachedBackend.prototype.set = function set(key, value, options) {
return this._clientSet(key, value, options.expire).then(_.constant(value));
const constant = () => value;
return this._clientSet(key, value, options.expire).then(constant);
};
MemcachedBackend.prototype.unset = function unset(key) {
return this._clientDel(key).then(_.noop);
return this._clientDel(key).then(noop);
};

@@ -74,0 +76,0 @@

@@ -41,3 +41,3 @@ /*

function MemoryBackend() {
this.cache = Object.create(null);
this.cache = new Map();
this.type = 'memory';

@@ -48,6 +48,6 @@ }

MemoryBackend.prototype.get = function get(key) {
let wrappedValue = this.cache[key] || null;
let wrappedValue = this.cache.get(key) || null;
if (util.isExpired(wrappedValue && wrappedValue.e)) {
wrappedValue = null;
delete this.cache[key];
this.cache.delete(key);
}

@@ -58,6 +58,6 @@ return Bluebird.resolve(wrappedValue ? wrappedValue.d : null);

MemoryBackend.prototype.set = function set(key, value, options) {
this.cache[key] = {
this.cache.set(key, {
d: value,
e: util.expiresAt(options.expire),
};
});
return Bluebird.resolve(value);

@@ -67,4 +67,4 @@ };

MemoryBackend.prototype.unset = function unset(key) {
delete this.cache[key];
this.cache.delete(key);
return Bluebird.resolve();
};

@@ -37,4 +37,2 @@ /*

const _ = require('lodash');
const Backend = require('./backend');

@@ -82,6 +80,7 @@ const getOrElse = require('./get-or-else');

}
return null;
};
Cache.prototype.prepareOptions = function prepareOptions(options) {
return _.extend({}, this.defaults, options);
return Object.assign({}, this.defaults, options);
};

@@ -124,2 +123,3 @@

};
// For backwards compatibility, eventually we should deprecate this.

@@ -126,0 +126,0 @@ // It *should* be a private API.

@@ -36,3 +36,2 @@ /*

const Bluebird = require('bluebird');
const _ = require('lodash');
const util = require('util');

@@ -42,7 +41,8 @@

let namedCaches = Object.create(null);
const namedCaches = new Map();
const getName = util.deprecate(function getName(name) {
return name || 'default';
}, 'Unnamed caches and caches with non-string names are deprecated.');
const getName = util.deprecate(
name => name || 'default',
'Unnamed caches and caches with non-string names are deprecated.'
);

@@ -54,13 +54,16 @@ function cached(name, options) {

if (!(name in namedCaches)) {
namedCaches[name] = cached.createCache(
_.extend(
{
name: name,
},
options || {}
if (!namedCaches.has(name)) {
namedCaches.set(
name,
cached.createCache(
Object.assign(
{
name: name,
},
options || {}
)
)
);
}
return namedCaches[name];
return namedCaches.get(name);
}

@@ -74,3 +77,3 @@ module.exports = cached;

cached.dropNamedCaches = function dropNamedCaches() {
namedCaches = Object.create(null);
namedCaches.clear();
return cached;

@@ -80,3 +83,3 @@ };

cached.dropNamedCache = function dropNamedCache(name) {
delete namedCaches[name];
namedCaches.delete(name);
return cached;

@@ -86,3 +89,3 @@ };

cached.knownCaches = function knownCaches() {
return Object.keys(namedCaches);
return [...namedCaches.keys()];
};

@@ -89,0 +92,0 @@

@@ -38,3 +38,2 @@ /*

const Bluebird = require('bluebird');
const _ = require('lodash');

@@ -81,6 +80,8 @@ const util = require('./util');

const hit = !!wrappedValue;
const expired = util.isExpired(wrappedValue && wrappedValue.b);
let loadingNewValue = cache.staleOrPending[key] !== undefined;
if ((!hit || expired) && !loadingNewValue) {
if (
!loadingNewValue &&
(!hit || util.isExpired(wrappedValue && wrappedValue.b))
) {
cache.staleOrPending[key] = refreshValue();

@@ -101,5 +102,5 @@ loadingNewValue = true;

._getWrapped(key)
.catch(_.constant(null))
.catch(() => null)
.then(verifyFreshness);
}
module.exports = getOrElse;
{
"name": "cached",
"version": "4.3.2",
"version": "5.0.0",
"description": "Simple access to a cache",

@@ -18,5 +18,8 @@ "license": "BSD-3-Clause",

"test": "mocha",
"posttest": "nlm verify",
"watch": "mocha --watch"
"posttest": "nlm verify"
},
"engines": {
"yarn": "0.0.0",
"npm": "^6.0.0"
},
"nlm": {

@@ -31,18 +34,15 @@ "license": {

"bluebird": "^3.3.3",
"lodash": "^4.6.1",
"memcached": "^2.1.0"
"memcached": "^2.2.2"
},
"devDependencies": {
"assertive": "^2.1.0",
"babel-cli": "^6.24.1",
"babel-core": "^5.8.33",
"babel-eslint": "^8.1.2",
"babel-preset-env": "^1.6.0",
"eslint": "^4.7.1",
"eslint-config-groupon": "^5.0.0",
"eslint-config-groupon": "^6.0.0",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-node": "^5.2.1",
"eslint-plugin-mocha": "^4.12.1",
"eslint-plugin-node": "^5.1.1",
"eslint-plugin-prettier": "^2.2.0",
"mocha": "^3.1.2",
"nlm": "^3.0.0",
"lodash": "^4.17.11",
"mocha": "^5.2.0",
"nlm": "^3.3.4",
"prettier": "^1.6.1"

@@ -49,0 +49,0 @@ },

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