Comparing version 0.2.0 to 0.2.1
@@ -28,3 +28,3 @@ var redis = require('redis') | ||
var deferred = Q.defer() | ||
this._client.setex(key, Math.floor(maxAgeMs / 1000), val, deferred.makeNodeResolver()) | ||
this._client.psetex(key, maxAgeMs, val, deferred.makeNodeResolver()) | ||
@@ -35,2 +35,19 @@ return deferred.promise | ||
RedisConnection.prototype.mset = function (items, maxAgeMs) { | ||
var deferred = Q.defer() | ||
var msetCommand = ["MSET"] | ||
var commands = [msetCommand] | ||
for (var i = 0, l = items.length; i < l; i++) { | ||
var key = items[i].key | ||
// Append key value arguments to the set command. | ||
msetCommand.push(key, items[i].value) | ||
// Append an expire command. | ||
commands.push(["PEXPIRE", key, maxAgeMs]) | ||
} | ||
this._client.multi(commands).exec(deferred.makeNodeResolver()) | ||
return deferred.promise | ||
.fail(warnOnError) | ||
} | ||
RedisConnection.prototype.del = function (key) { | ||
@@ -37,0 +54,0 @@ var deferred = Q.defer() |
@@ -87,6 +87,12 @@ var util = require('util') | ||
RedundantCacheGroup.prototype.mset = function (items, maxAgeMs) { | ||
var instance = this._getAvailableInstance() | ||
if (!instance) return Q.resolve(undefined) | ||
return instance.mset(items, maxAgeMs) | ||
} | ||
RedundantCacheGroup.prototype.set = function (key, val, maxAgeMs) { | ||
var instances = this._getAllInstances() | ||
var promises = [] | ||
for (var i = 0; i < instances.length; i++) { | ||
@@ -93,0 +99,0 @@ promises.push(instances[i].set(key, val, maxAgeMs)) |
{ | ||
"name": "zcache" | ||
, "description": "AWS zone-aware caching" | ||
, "version": "0.2.0" | ||
, "version": "0.2.1" | ||
, "homepage": "https://github.com/azulus/zcache" | ||
@@ -6,0 +6,0 @@ , "authors": [ |
@@ -47,2 +47,19 @@ var zcache = require('../index') | ||
test.equal(vals[0], undefined) | ||
}) | ||
.then(function () { | ||
return cacheInstance.mset([{ | ||
key: 'a', | ||
value: '456' | ||
}, { | ||
key: 'b', | ||
value: '789' | ||
}], 300000) | ||
}) | ||
.then(function () { | ||
return cacheInstance.mget(['a', 'b']) | ||
}) | ||
.then(function (vals) { | ||
test.equal(vals.length, 2, "Should have precisely 2 results") | ||
test.equal(vals[0], '456') | ||
test.equal(vals[1], '789') | ||
cacheInstance.destroy() | ||
@@ -63,2 +80,2 @@ }) | ||
cacheInstance.connect() | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
71573
25
1581
1