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) { 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');