From dcd7df3596a857b26fe9058562f3f3f61e7c3e92 Mon Sep 17 00:00:00 2001 From: jawsome Date: Sat, 3 Aug 2013 09:21:53 -0500 Subject: [PATCH 1/2] Add purgeall() cache function. --- lib/cradle/cache.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/cradle/cache.js b/lib/cradle/cache.js index 5b60877..c58a4a9 100644 --- a/lib/cradle/cache.js +++ b/lib/cradle/cache.js @@ -89,7 +89,10 @@ this.Cache.prototype = { that.keys -= pruned; }); } - } + }, + purgeall: function() { + this.store = []; + this.keys = 0; }; function clone(obj) { From 246e4b9e3dfe010b0af3730cf5e1357dc0cf3f45 Mon Sep 17 00:00:00 2001 From: jawsome Date: Sat, 3 Aug 2013 09:22:13 -0500 Subject: [PATCH 2/2] Purge all database cache when destroying. #149 --- lib/cradle/database/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/cradle/database/index.js b/lib/cradle/database/index.js index f56fdd9..e1485c3 100644 --- a/lib/cradle/database/index.js +++ b/lib/cradle/database/index.js @@ -48,12 +48,12 @@ Database.prototype.create = function (callback) { Database.prototype.destroy = function (callback) { if (arguments.length > 1) { throw new(Error)("destroy() doesn't take any additional arguments"); - } - + } + this.cache.purgeall(); this.query({ method: 'DELETE', path: '/', - }, callback); + }, callback); }; // @@ -62,4 +62,4 @@ Database.prototype.destroy = function (callback) { require('./attachments'); require('./changes'); require('./documents'); -require('./views'); \ No newline at end of file +require('./views');