From cb88ca17431a078e1e83263466ff6dd07e986ef2 Mon Sep 17 00:00:00 2001 From: Bryan Donovan Date: Sun, 13 Oct 2013 19:06:38 -0700 Subject: [PATCH] Wrapping synchronous memory cache callbacks in process.nextTick() --- History.md | 5 ++++- lib/stores/memory.js | 8 +++++--- package.json | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/History.md b/History.md index 681efe9..c858854 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,6 @@ +- 0.1.2 2013-10-13 + Wrapping synchronous memory cache callbacks in process.nextTick() for the purists. + - 0.1.1 2013-10-13 Travis and Coveralls integration testing. @@ -18,7 +21,7 @@ Added ability to pass in a store module that isn't already instantiated. E.g., ```javascript - var store = require('/path/my_memory_store'); + var store = require('/path/to/my_memory_store'); cache = caching({store: store}); ``` - 0.0.1 2013-04-08 diff --git a/lib/stores/memory.js b/lib/stores/memory.js index 13593aa..7c27f66 100644 --- a/lib/stores/memory.js +++ b/lib/stores/memory.js @@ -15,18 +15,20 @@ var memory_store = function (args) { self.set = function (key, value, cb) { lru_cache.set(key, value); if (cb) { - cb(null); + process.nextTick(cb); } }; self.get = function (key, cb) { - cb(null, lru_cache.get(key)); + process.nextTick(function () { + cb(null, lru_cache.get(key)); + }); }; self.del = function (key, cb) { lru_cache.del(key); if (cb) { - cb(null); + process.nextTick(cb); } }; diff --git a/package.json b/package.json index 728bb72..d9af53f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cache-manager", - "version": "0.1.1", + "version": "0.1.2", "description": "Cache module for Node.js", "main": "index.js", "scripts": {