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

deep-cache

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deep-cache - npm Package Compare versions

Comparing version 1.6.3 to 1.6.4

19

lib.compiled/Cache.js

@@ -57,3 +57,3 @@ /**

* @param {String} name
* @param {Array} args
* @param {*} args
* @returns {AbstractDriver}

@@ -72,19 +72,12 @@ */

value: function boot(kernel, callback) {
var sharedCacheDriver = undefined;
var driver = undefined;
if (kernel.isFrontend) {
driver = Cache.createDriver('local-storage');
sharedCacheDriver = Cache.createDriver('cloud-front', this);
} else {
// @todo: switch to redis when issue with Elasticache is fixed
driver = Cache.createDriver('memory');
sharedCacheDriver = Cache.createDriver('s3fs', this);
}
// @todo: remove in memory fallback for backend?
this._driver = kernel.isFrontend ? Cache.createDriver('local-storage') : kernel.config.cacheDsn ? Cache.createDriver('redis', kernel.config.cacheDsn) : Cache.createDriver('memory');
[driver, sharedCacheDriver].map(function (driver) {
var sharedCacheDriver = kernel.isFrontend ? Cache.createDriver('cloud-front', this) : Cache.createDriver('s3fs', this);
[this._driver, sharedCacheDriver].map(function (driver) {
driver.buildId = kernel.buildId;
});
this._driver = driver;
this._shared = new _SharedCache.SharedCache(sharedCacheDriver);

@@ -91,0 +84,0 @@

@@ -29,2 +29,6 @@ /**

var _ecad = require('ecad');
var _ecad2 = _interopRequireDefault(_ecad);
/**

@@ -46,9 +50,10 @@ * Redis/Elasticache driver implementation

var nativeDriver = this.NATIVE_DRIVER;
this._autoDiscoveryError = null;
this._client = null;
this._client = dsn ? new nativeDriver(dsn) : new nativeDriver();
this._autoDiscover(dsn);
}
/**
* @returns {String}
* @param {String} dsn
* @private

@@ -58,2 +63,60 @@ */

_createClass(RedisDriver, [{
key: '_autoDiscover',
value: function _autoDiscover(dsn) {
var _this = this;
var payload = {
endpoints: [dsn],
timeout: RedisDriver.DEFAULT_AUTO_DISCOVERY_TIMEOUT
};
var client = new _ecad2['default'](payload);
client.fetch(function (error, hosts) {
if (error) {
_this._autoDiscoveryError = error;
} else {
(function () {
var options = {
sentinels: [],
name: dsn
};
hosts.forEach(function (host) {
options.sentinels.push('redis://' + host + '/');
});
_this._client = new _this.NATIVE_DRIVER(options);
})();
}
});
}
/**
* @param {Function} cb
* @private
*/
}, {
key: 'clientWait',
value: function clientWait(cb) {
var _this2 = this;
if (this._client) {
cb(null, this._client);
} else if (this._autoDiscoveryError) {
cb(this._autoDiscoveryError, null);
} else {
setTimeout(function () {
process.nextTick(function () {
_this2.clientWait(cb);
});
}, RedisDriver.CLIENT_WAIT_MS_INTERVAL);
}
}
/**
* @returns {String}
* @private
*/
}, {
key: '_type',

@@ -65,3 +128,3 @@ value: function _type() {

/**
* @returns {Redis}
* @returns {Error|String|null}
*/

@@ -78,10 +141,16 @@ }, {

this._client.exists(key, function (error, results) {
this.clientWait(function (error, client) {
if (error) {
callback(new _ExceptionRedisClusterException.RedisClusterException(error), null);
return;
}
callback(null, results);
client.exists(key, function (error, results) {
if (error) {
callback(new _ExceptionRedisClusterException.RedisClusterException(error), null);
return;
}
callback(null, results);
});
});

@@ -99,10 +168,17 @@ }

this._client.get(key, function (error, results) {
this.clientWait(function (error, client) {
if (error) {
callback(new _ExceptionRedisClusterException.RedisClusterException(error), null);
return;
}
callback(null, results);
client.get(key, function (error, results) {
if (error) {
callback(new _ExceptionRedisClusterException.RedisClusterException(error), null);
return;
}
callback(null, results);
});
});

@@ -124,10 +200,17 @@ }

this._client.set(key, value, ttl, function (error) {
this.clientWait(function (error, client) {
if (error) {
callback(new _ExceptionRedisClusterException.RedisClusterException(error), null);
return;
}
callback(null, true);
client.set(key, value, ttl, function (error) {
if (error) {
callback(new _ExceptionRedisClusterException.RedisClusterException(error), null);
return;
}
callback(null, true);
});
});

@@ -147,10 +230,17 @@ }

this._client.del(key, timeout, function (error) {
this.clientWait(function (error, client) {
if (error) {
callback(new _ExceptionRedisClusterException.RedisClusterException(error), null);
return;
}
callback(null, true);
client.del(key, timeout, function (error) {
if (error) {
callback(new _ExceptionRedisClusterException.RedisClusterException(error), null);
return;
}
callback(null, true);
});
});

@@ -168,10 +258,17 @@ }

this._client.flushall(function (error) {
this.clientWait(function (error, client) {
if (error) {
callback(new _ExceptionRedisClusterException.RedisClusterException(error), null);
return;
}
callback(null, true);
client.flushall(function (error) {
if (error) {
callback(new _ExceptionRedisClusterException.RedisClusterException(error), null);
return;
}
callback(null, true);
});
});

@@ -185,2 +282,11 @@ }

}, {
key: 'autoDiscoveryError',
get: function get() {
return this._autoDiscoveryError;
}
/**
* @returns {Redis}
*/
}, {
key: 'client',

@@ -195,2 +301,20 @@ get: function get() {

}
/**
* @returns {Number}
*/
}], [{
key: 'CLIENT_WAIT_MS_INTERVAL',
get: function get() {
return 5;
}
/**
* @returns {Number}
*/
}, {
key: 'DEFAULT_AUTO_DISCOVERY_TIMEOUT',
get: function get() {
return 700;
}
}]);

@@ -197,0 +321,0 @@

{
"name": "deep-cache",
"version": "1.6.3",
"version": "1.6.4",
"description": "DEEP Cache Library",

@@ -66,2 +66,3 @@ "keywords": [

"ioredis": "^1.5.x",
"ecad": "^0.2.x",
"store": "^1.3.x"

@@ -68,0 +69,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