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

petty-cache

Package Overview
Dependencies
Maintainers
2
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

petty-cache - npm Package Compare versions

Comparing version 3.0.1 to 3.1.0

CHANGELOG.md

53

index.js

@@ -79,3 +79,3 @@ const async = require('async');

// Default TTL is 30-60 seconds
var ttl = {
const ttl = {
max: 60000,

@@ -106,3 +106,9 @@ min: 30000

*/
this.bulkFetch = function(keys, func, callback) {
this.bulkFetch = function(keys, func, options, callback) {
// Options are optional
if (!callback) {
callback = options;
options = {};
}
// If there aren't any keys, return

@@ -166,3 +172,3 @@ if (!keys.length) {

_this.bulkSet(data, err => callback(err, values));
_this.bulkSet(data, options, err => callback(err, values));
});

@@ -232,7 +238,10 @@ });

// Get TTL based on specified options
const ttl = getTtl(options);
// Redis does not have a MSETEX command so we batch commands: http://redis.js.org/#api-clientbatchcommands
var batch = redisClient.batch();
const batch = redisClient.batch();
Object.keys(values).forEach(key => {
var value = values[key];
const value = values[key];

@@ -242,23 +251,2 @@ // Store value in memory cache with a short expiration

// Default TTL is 30-60 seconds
var ttl = {
max: 60000,
min: 30000
};
if (Object.prototype.hasOwnProperty.call(options, 'ttl')) {
if (typeof options.ttl === 'number') {
ttl.max = options.ttl;
ttl.min = options.ttl;
} else {
if (Object.prototype.hasOwnProperty.call(options.ttl, 'max')) {
ttl.max = options.ttl.max;
}
if (Object.prototype.hasOwnProperty.call(options.ttl, 'min')) {
ttl.min = options.ttl.min;
}
}
}
// Add Redis command

@@ -391,11 +379,12 @@ batch.psetex(key, random(ttl.min, ttl.max), PettyCache.stringify(value));

// Get TTL based on specified options
const ttl = getTtl(options);
// Default callback is a noop
callback = callback || function() {};
options.ttl = getTtl(options);
const _this = this;
if (!intervals[key]) {
const delay = options.ttl.min / 2;
const delay = ttl.min / 2;

@@ -826,2 +815,5 @@ intervals[key] = setInterval(function() {

// Get TTL based on specified options
const ttl = getTtl(options);
// Default callback is a noop

@@ -833,5 +825,2 @@ callback = callback || function() {};

// Get TTL based on specified options
const ttl = getTtl(options);
// Store value is Redis

@@ -838,0 +827,0 @@ redisClient.psetex(key, random(ttl.min, ttl.max), PettyCache.stringify(value), callback);

@@ -11,3 +11,3 @@ {

"coveralls": "*",
"istanbul": "*",
"nyc": "*",
"mocha": "*"

@@ -27,3 +27,3 @@ },

"scripts": {
"coveralls": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- --exit --reporter spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage",
"coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls",
"test": "mocha --exit --reporter spec"

@@ -35,3 +35,3 @@ },

},
"version": "3.0.1"
"version": "3.1.0"
}
# petty-cache
[![Build Status](https://travis-ci.org/mediocre/petty-cache.svg?branch=master)](https://travis-ci.org/mediocre/petty-cache)
[![Build Status](https://github.com/mediocre/petty-cache/workflows/build/badge.svg)](https://github.com/mediocre/petty-cache/actions?query=workflow%3Abuild)
[![Coverage Status](https://coveralls.io/repos/github/mediocre/petty-cache/badge.svg?branch=master)](https://coveralls.io/github/mediocre/petty-cache?branch=master)

@@ -79,2 +79,4 @@

}
callback(null, results);
}, function(err, values) {

@@ -81,0 +83,0 @@ console.log(values); // {a: 1, b: 2, c: 'C', d: 'D'}

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