diff --git a/CHANGELOG.md b/CHANGELOG.md index b9354af..ac17a55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +##### 1.2.0 - 12 July 2015 + +###### Backwards compatible API changes +- #2 - Specify MaxAge on put + +###### Bug fixes +- #1 - After reinitializing a cache from localStorage, info().size returns 0 + ##### 1.1.0 - 10 July 2015 Upgraded dependencies diff --git a/Gruntfile.js b/Gruntfile.js index 7ce21bc..2048487 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -101,6 +101,17 @@ module.exports = function (grunt) { 'test/**/*.js' ] } + }, + c9: { + browsers: ['PhantomJS'], + options: { + files: [ + 'node_modules/es6-promise/dist/es6-promise.js', + 'dist/cachefactory.min.js', + './karma.start.js', + 'test/**/*.js' + ] + } } }, coveralls: { @@ -111,6 +122,7 @@ module.exports = function (grunt) { }); grunt.registerTask('test', ['build', 'karma:dist', 'karma:min']); + grunt.registerTask('test_c9', ['build', 'karma:c9']); grunt.registerTask('build', [ 'clean', 'webpack', diff --git a/README.md b/README.md index ff53aaf..ae54705 100644 --- a/README.md +++ b/README.md @@ -4,14 +4,6 @@ CacheFactory is a very simple and useful cache. __Latest Release:__ [![Latest Release](https://img.shields.io/github/release/jmdobry/cachefactory.svg?style=flat-square)](https://github.com/jmdobry/cachefactory/releases) -__Status:__ - -[![Dependency Status](https://img.shields.io/gemnasium/jmdobry/cachefactory.svg?style=flat-square)](https://gemnasium.com/jmdobry/cachefactory) [![Coverage Status](https://img.shields.io/coveralls/jmdobry/cachefactory/master.svg?style=flat-square)](https://coveralls.io/r/jmdobry/cachefactory?branch=master) [![Codacity](https://img.shields.io/codacy/5e27e21d0c4c4d4cb203d589384aa93a.svg?style=flat-square)](https://www.codacy.com/public/jasondobry/cachefactory/dashboard) - -__Supported Browsers:__ - -[![browsers](https://img.shields.io/badge/Browser-Chrome%2CFirefox%2CSafari%2COpera%2CIE%209%2B%2CiOS%20Safari%207.1%2B%2CAndroid%20Browser%202.3%2B-green.svg?style=flat-square)](https://github.com/jmdobry/cachefactory) - ### Table of Contents - [Quick Start](#quick-start) - [The Basics](#the-basics) @@ -195,6 +187,12 @@ Will be passed a third `done` argument if the cache is in `passive` mode. This a The number of milliseconds until a newly inserted item expires. Default: `Number.MAX_VALUE`. +You can also specify a `maxAge` for an individual item like so: + +```js +myCache.put('foo', 'bar', { maxAge: 60000 }); +``` + ##### `recycleFreq` Determines how often a cache will scan for expired items when in `aggressive` mode. Default: `1000` (milliseconds). diff --git a/dist/cachefactory.js b/dist/cachefactory.js index ba637db..7e96420 100644 --- a/dist/cachefactory.js +++ b/dist/cachefactory.js @@ -1,6 +1,6 @@ /*! * cachefactory - * @version 1.1.0 - Homepage + * @version 1.2.0 - Homepage * @author Jason Dobry * @copyright (c) 2013-2015 Jason Dobry * @license MIT @@ -11,7 +11,7 @@ if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) - define(factory); + define([], factory); else if(typeof exports === 'object') exports["CacheFactory"] = factory(); else @@ -299,7 +299,7 @@ return /******/ (function(modules) { // webpackBootstrap created: item.created, accessed: item.accessed, expires: item.expires, - isExpired: new Date().getTime() - item.created > this.$$maxAge + isExpired: new Date().getTime() - item.created > (item.maxAge || this.$$maxAge) }; } else { return undefined; @@ -312,7 +312,7 @@ return /******/ (function(modules) { // webpackBootstrap created: item.created, accessed: item.accessed, expires: item.expires, - isExpired: new Date().getTime() - item.created > this.$$maxAge + isExpired: new Date().getTime() - item.created > (item.maxAge || this.$$maxAge) }; } else { return undefined; @@ -415,7 +415,11 @@ return /******/ (function(modules) { // webpackBootstrap accessed: now }; - item.expires = item.created + this.$$maxAge; + if (options.maxAge) { + item.maxAge = options.maxAge; + } + + item.expires = item.created + (item.maxAge || this.$$maxAge); if ($$storage) { if (_isPromiseLike(item.value)) { @@ -651,7 +655,7 @@ return /******/ (function(modules) { // webpackBootstrap if (this.$$maxAge === Number.MAX_VALUE) { item.expires = Number.MAX_VALUE; } else { - item.expires = item.created + this.$$maxAge; + item.expires = item.created + (item.maxAge || this.$$maxAge); } $$expiresHeap.push({ key: key, @@ -667,7 +671,7 @@ return /******/ (function(modules) { // webpackBootstrap if (this.$$maxAge === Number.MAX_VALUE) { $$data[key].expires = Number.MAX_VALUE; } else { - $$data[key].expires = $$data[key].created + this.$$maxAge; + $$data[key].expires = $$data[key].created + ($$data[key].maxAge || this.$$maxAge); } $$expiresHeap.push($$data[key]); } @@ -797,18 +801,16 @@ return /******/ (function(modules) { // webpackBootstrap var shouldReInsert = false; var items = {}; - if (typeof this.$$storageMode === 'string' && this.$$storageMode !== storageMode) { - var keys = this.keys(); + var keys = this.keys(); - if (keys.length) { - for (var i = 0; i < keys.length; i++) { - items[keys[i]] = this.get(keys[i]); - } - for (i = 0; i < keys.length; i++) { - this.remove(keys[i]); - } - shouldReInsert = true; + if (keys.length) { + for (var i = 0; i < keys.length; i++) { + items[keys[i]] = this.get(keys[i]); + } + for (i = 0; i < keys.length; i++) { + this.remove(keys[i]); } + shouldReInsert = true; } this.$$storageMode = storageMode; diff --git a/dist/cachefactory.min.js b/dist/cachefactory.min.js index 0f456c5..8bf7701 100644 --- a/dist/cachefactory.min.js +++ b/dist/cachefactory.min.js @@ -1,6 +1,6 @@ /*! * cachefactory -* @version 1.1.0 - Homepage +* @version 1.2.0 - Homepage * @author Jason Dobry * @copyright (c) 2013-2015 Jason Dobry * @license MIT @@ -8,5 +8,5 @@ * @overview cachefactory is a very useful replacement for Angular's $cacheFactory. */ -!function(a,b){"object"==typeof exports&&"object"==typeof module?module.exports=b():"function"==typeof define&&define.amd?define(b):"object"==typeof exports?exports.CacheFactory=b():a.CacheFactory=b()}(this,function(){return function(a){function b(d){if(c[d])return c[d].exports;var e=c[d]={exports:{},id:d,loaded:!1};return a[d].call(e.exports,e,e.exports,b),e.loaded=!0,e.exports}var c={};return b.m=a,b.c=c,b.p="",b(0)}([function(a,b,c){function d(a,b){return o(a,b)}var e=c(1),f=null;try{f=window.Promise}catch(g){}var h={isNumber:function(a){return"number"==typeof a},isString:function(a){return"string"==typeof a},isObject:function(a){return null!==a&&"object"==typeof a},isFunction:function(a){return"function"==typeof a},fromJson:function(a){return JSON.parse(a)},equals:function(a,b){return a===b},Promise:f},i=function(a){var b=[],c=void 0;for(c in a)a.hasOwnProperty(c)&&b.push(c);return b},j=function(a){return a&&"function"==typeof a.then},k=function(a){return h.isNumber(a)?a.toString():a},l=function(a){var b={},c=void 0;for(c in a)a.hasOwnProperty(c)&&(b[c]=c);return b},m={capacity:Number.MAX_VALUE,maxAge:Number.MAX_VALUE,deleteOnExpire:"none",onExpire:null,cacheFlushInterval:null,recycleFreq:1e3,storageMode:"memory",storageImpl:null,disabled:!1,storagePrefix:"cachefactory.caches.",storeOnResolve:!1,storeOnReject:!1},n={},o=function(a,b){if(a in n)throw new Error(a+" already exists!");if(!h.isString(a))throw new Error("cacheId must be a string!");var c={},d={},f=null,g=new e(function(a){return a.expires},h.equals),o=new e(function(a){return a.accessed},h.equals),p=n[a]={$$id:a,destroy:function(){clearInterval(this.$$cacheFlushIntervalId),clearInterval(this.$$recycleFreqId),this.removeAll(),f&&(f().removeItem(this.$$prefix+".keys"),f().removeItem(this.$$prefix)),f=null,c=null,o=null,g=null,this.$$prefix=null,delete n[this.$$id]},disable:function(){this.$$disabled=!0},enable:function(){delete this.$$disabled},get:function(a,b){var e=this;if(Array.isArray(a)){var g=function(){var c=a,d=[];return c.forEach(function(a){var c=e.get(a,b);null!==c&&void 0!==c&&d.push(c)}),{v:d}}();if("object"==typeof g)return g.v}else if(a=k(a),this.$$disabled)return;if(b=b||{},!h.isString(a))throw new Error("key must be a string!");if(b&&!h.isObject(b))throw new Error("options must be an object!");if(b.onExpire&&!h.isFunction(b.onExpire))throw new Error("options.onExpire must be a function!");var i=void 0;if(f){if(d[a])return d[a];var j=f().getItem(this.$$prefix+".data."+a);if(!j)return;i=h.fromJson(j)}else{if(!(a in c))return;i=c[a]}var l=i.value,m=(new Date).getTime();return f?(o.remove({key:a,accessed:i.accessed}),i.accessed=m,o.push({key:a,accessed:m})):(o.remove(i),i.accessed=m,o.push(i)),"passive"===this.$$deleteOnExpire&&"expires"in i&&i.expiresthis.$$maxAge}):void 0}return a in c?(b=c[a],{created:b.created,accessed:b.accessed,expires:b.expires,isExpired:(new Date).getTime()-b.created>this.$$maxAge}):void 0}return{id:this.$$id,capacity:this.$$capacity,maxAge:this.$$maxAge,deleteOnExpire:this.$$deleteOnExpire,onExpire:this.$$onExpire,cacheFlushInterval:this.$$cacheFlushInterval,recycleFreq:this.$$recycleFreq,storageMode:this.$$storageMode,storageImpl:f?f():void 0,disabled:!!this.$$disabled,size:o&&o.size()||0}},keys:function(){if(f){var a=f().getItem(this.$$prefix+".keys");return a?h.fromJson(a):[]}return i(c)},keySet:function(){if(f){var a=f().getItem(this.$$prefix+".keys"),b={};if(a)for(var d=h.fromJson(a),e=0;ethis.$$capacity&&this.remove(o.peek().key),b}},remove:function(a){if(a+="",delete d[a],!f){var b=c[a]?c[a].value:void 0;return o.remove(c[a]),g.remove(c[a]),c[a]=null,delete c[a],b}var e=f().getItem(this.$$prefix+".data."+a);if(e){var i=h.fromJson(e);o.remove({key:a,accessed:i.accessed}),g.remove({key:a,expires:i.expires}),f().removeItem(this.$$prefix+".data."+a);var j=f().getItem(this.$$prefix+".keys"),k=j?h.fromJson(j):[],l=k.indexOf(a);return l>=0&&k.splice(l,1),f().setItem(this.$$prefix+".keys",JSON.stringify(k)),i.value}},removeAll:function(){if(f){o.removeAll(),g.removeAll();var a=f().getItem(this.$$prefix+".keys");if(a)for(var b=h.fromJson(a),e=0;ea)throw new Error("cacheFlushInterval must be greater than zero!");a!==this.$$cacheFlushInterval&&(this.$$cacheFlushInterval=a,clearInterval(this.$$cacheFlushIntervalId),function(a){a.$$cacheFlushIntervalId=setInterval(function(){a.removeAll()},a.$$cacheFlushInterval)}(this))}},setCapacity:function(a){if(null===a)delete this.$$capacity;else{if(!h.isNumber(a))throw new Error("capacity must be a number!");if(0>a)throw new Error("capacity must be greater than zero!");this.$$capacity=a}for(var b={};o.size()>this.$$capacity;)b[o.peek().key]=this.remove(o.peek().key);return b},setDeleteOnExpire:function(a,b){if(null===a)delete this.$$deleteOnExpire;else{if(!h.isString(a))throw new Error("deleteOnExpire must be a string!");if("none"!==a&&"passive"!==a&&"aggressive"!==a)throw new Error('deleteOnExpire must be "none", "passive" or "aggressive"!');this.$$deleteOnExpire=a}b!==!1&&this.setRecycleFreq(this.$$recycleFreq)},setMaxAge:function(a){if(null===a)this.$$maxAge=Number.MAX_VALUE;else{if(!h.isNumber(a))throw new Error("maxAge must be a number!");if(0>a)throw new Error("maxAge must be greater than zero!");this.$$maxAge=a}var b=void 0,d=void 0,e=void 0;if(g.removeAll(),f){var j=f().getItem(this.$$prefix+".keys");for(d=j?h.fromJson(j):[],b=0;ba)throw new Error("recycleFreq must be greater than zero!");this.$$recycleFreq=a}clearInterval(this.$$recycleFreqId),"aggressive"===this.$$deleteOnExpire?!function(a){a.$$recycleFreqId=setInterval(function(){a.removeExpired()},a.$$recycleFreq)}(this):delete this.$$recycleFreqId},setStorageMode:function(a,b){if(!h.isString(a))throw new Error("storageMode must be a string!");if("memory"!==a&&"localStorage"!==a&&"sessionStorage"!==a)throw new Error('storageMode must be "memory", "localStorage" or "sessionStorage"!');var c=!1,d={};if("string"==typeof this.$$storageMode&&this.$$storageMode!==a){var e=this.keys();if(e.length){for(var g=0;g0;){var f=Math.floor((c+1)/2)-1,g=a[f];if(e>=b(g))break;a[f]=d,a[c]=g,c=f}}function e(a,b){if(a||(a=function(a){return a}),b||(b=function(a,b){return a===b}),"function"!=typeof a)throw new Error('BinaryHeap([weightFunc][, compareFunc]): "weightFunc" must be a function!');if("function"!=typeof b)throw new Error('BinaryHeap([weightFunc][, compareFunc]): "compareFunc" must be a function!');this.weightFunc=a,this.compareFunc=b,this.heap=[]}var f=function(a,b,c){for(var d=a.length,e=a[c],f=b(e);;){var g=2*(c+1),h=g-1,i=null;if(d>h){var j=a[h],k=b(j);f>k&&(i=h)}if(d>g){var l=a[g],m=b(l);m<(null===i?f:b(a[h]))&&(i=g)}if(null===i)break;a[c]=a[i],a[i]=e,c=i}},g=e.prototype;g.push=function(a){this.heap.push(a),d(this.heap,this.weightFunc,this.heap.length-1)},g.peek=function(){return this.heap[0]},g.pop=function(){var a=this.heap[0],b=this.heap.pop();return this.heap.length>0&&(this.heap[0]=b,f(this.heap,this.weightFunc,0)),a},g.remove=function(a){for(var b=this.heap.length,c=0;b>c;c++)if(this.compareFunc(this.heap[c],a)){var e=this.heap[c],g=this.heap.pop();return c!==b-1&&(this.heap[c]=g,d(this.heap,this.weightFunc,c),f(this.heap,this.weightFunc,c)),e}return null},g.removeAll=function(){this.heap=[]},g.size=function(){return this.heap.length},a.exports=e}])})}])}); +!function(a,b){"object"==typeof exports&&"object"==typeof module?module.exports=b():"function"==typeof define&&define.amd?define([],b):"object"==typeof exports?exports.CacheFactory=b():a.CacheFactory=b()}(this,function(){return function(a){function b(d){if(c[d])return c[d].exports;var e=c[d]={exports:{},id:d,loaded:!1};return a[d].call(e.exports,e,e.exports,b),e.loaded=!0,e.exports}var c={};return b.m=a,b.c=c,b.p="",b(0)}([function(a,b,c){function d(a,b){return o(a,b)}var e=c(1),f=null;try{f=window.Promise}catch(g){}var h={isNumber:function(a){return"number"==typeof a},isString:function(a){return"string"==typeof a},isObject:function(a){return null!==a&&"object"==typeof a},isFunction:function(a){return"function"==typeof a},fromJson:function(a){return JSON.parse(a)},equals:function(a,b){return a===b},Promise:f},i=function(a){var b=[],c=void 0;for(c in a)a.hasOwnProperty(c)&&b.push(c);return b},j=function(a){return a&&"function"==typeof a.then},k=function(a){return h.isNumber(a)?a.toString():a},l=function(a){var b={},c=void 0;for(c in a)a.hasOwnProperty(c)&&(b[c]=c);return b},m={capacity:Number.MAX_VALUE,maxAge:Number.MAX_VALUE,deleteOnExpire:"none",onExpire:null,cacheFlushInterval:null,recycleFreq:1e3,storageMode:"memory",storageImpl:null,disabled:!1,storagePrefix:"cachefactory.caches.",storeOnResolve:!1,storeOnReject:!1},n={},o=function(a,b){if(a in n)throw new Error(a+" already exists!");if(!h.isString(a))throw new Error("cacheId must be a string!");var c={},d={},f=null,g=new e(function(a){return a.expires},h.equals),o=new e(function(a){return a.accessed},h.equals),p=n[a]={$$id:a,destroy:function(){clearInterval(this.$$cacheFlushIntervalId),clearInterval(this.$$recycleFreqId),this.removeAll(),f&&(f().removeItem(this.$$prefix+".keys"),f().removeItem(this.$$prefix)),f=null,c=null,o=null,g=null,this.$$prefix=null,delete n[this.$$id]},disable:function(){this.$$disabled=!0},enable:function(){delete this.$$disabled},get:function(a,b){var e=this;if(Array.isArray(a)){var g=function(){var c=a,d=[];return c.forEach(function(a){var c=e.get(a,b);null!==c&&void 0!==c&&d.push(c)}),{v:d}}();if("object"==typeof g)return g.v}else if(a=k(a),this.$$disabled)return;if(b=b||{},!h.isString(a))throw new Error("key must be a string!");if(b&&!h.isObject(b))throw new Error("options must be an object!");if(b.onExpire&&!h.isFunction(b.onExpire))throw new Error("options.onExpire must be a function!");var i=void 0;if(f){if(d[a])return d[a];var j=f().getItem(this.$$prefix+".data."+a);if(!j)return;i=h.fromJson(j)}else{if(!(a in c))return;i=c[a]}var l=i.value,m=(new Date).getTime();return f?(o.remove({key:a,accessed:i.accessed}),i.accessed=m,o.push({key:a,accessed:m})):(o.remove(i),i.accessed=m,o.push(i)),"passive"===this.$$deleteOnExpire&&"expires"in i&&i.expires(b.maxAge||this.$$maxAge)}):void 0}return a in c?(b=c[a],{created:b.created,accessed:b.accessed,expires:b.expires,isExpired:(new Date).getTime()-b.created>(b.maxAge||this.$$maxAge)}):void 0}return{id:this.$$id,capacity:this.$$capacity,maxAge:this.$$maxAge,deleteOnExpire:this.$$deleteOnExpire,onExpire:this.$$onExpire,cacheFlushInterval:this.$$cacheFlushInterval,recycleFreq:this.$$recycleFreq,storageMode:this.$$storageMode,storageImpl:f?f():void 0,disabled:!!this.$$disabled,size:o&&o.size()||0}},keys:function(){if(f){var a=f().getItem(this.$$prefix+".keys");return a?h.fromJson(a):[]}return i(c)},keySet:function(){if(f){var a=f().getItem(this.$$prefix+".keys"),b={};if(a)for(var d=h.fromJson(a),e=0;ethis.$$capacity&&this.remove(o.peek().key),b}},remove:function(a){if(a+="",delete d[a],!f){var b=c[a]?c[a].value:void 0;return o.remove(c[a]),g.remove(c[a]),c[a]=null,delete c[a],b}var e=f().getItem(this.$$prefix+".data."+a);if(e){var i=h.fromJson(e);o.remove({key:a,accessed:i.accessed}),g.remove({key:a,expires:i.expires}),f().removeItem(this.$$prefix+".data."+a);var j=f().getItem(this.$$prefix+".keys"),k=j?h.fromJson(j):[],l=k.indexOf(a);return l>=0&&k.splice(l,1),f().setItem(this.$$prefix+".keys",JSON.stringify(k)),i.value}},removeAll:function(){if(f){o.removeAll(),g.removeAll();var a=f().getItem(this.$$prefix+".keys");if(a)for(var b=h.fromJson(a),e=0;ea)throw new Error("cacheFlushInterval must be greater than zero!");a!==this.$$cacheFlushInterval&&(this.$$cacheFlushInterval=a,clearInterval(this.$$cacheFlushIntervalId),function(a){a.$$cacheFlushIntervalId=setInterval(function(){a.removeAll()},a.$$cacheFlushInterval)}(this))}},setCapacity:function(a){if(null===a)delete this.$$capacity;else{if(!h.isNumber(a))throw new Error("capacity must be a number!");if(0>a)throw new Error("capacity must be greater than zero!");this.$$capacity=a}for(var b={};o.size()>this.$$capacity;)b[o.peek().key]=this.remove(o.peek().key);return b},setDeleteOnExpire:function(a,b){if(null===a)delete this.$$deleteOnExpire;else{if(!h.isString(a))throw new Error("deleteOnExpire must be a string!");if("none"!==a&&"passive"!==a&&"aggressive"!==a)throw new Error('deleteOnExpire must be "none", "passive" or "aggressive"!');this.$$deleteOnExpire=a}b!==!1&&this.setRecycleFreq(this.$$recycleFreq)},setMaxAge:function(a){if(null===a)this.$$maxAge=Number.MAX_VALUE;else{if(!h.isNumber(a))throw new Error("maxAge must be a number!");if(0>a)throw new Error("maxAge must be greater than zero!");this.$$maxAge=a}var b=void 0,d=void 0,e=void 0;if(g.removeAll(),f){var j=f().getItem(this.$$prefix+".keys");for(d=j?h.fromJson(j):[],b=0;ba)throw new Error("recycleFreq must be greater than zero!");this.$$recycleFreq=a}clearInterval(this.$$recycleFreqId),"aggressive"===this.$$deleteOnExpire?!function(a){a.$$recycleFreqId=setInterval(function(){a.removeExpired()},a.$$recycleFreq)}(this):delete this.$$recycleFreqId},setStorageMode:function(a,b){if(!h.isString(a))throw new Error("storageMode must be a string!");if("memory"!==a&&"localStorage"!==a&&"sessionStorage"!==a)throw new Error('storageMode must be "memory", "localStorage" or "sessionStorage"!');var c=!1,d={},e=this.keys();if(e.length){for(var g=0;g0;){var f=Math.floor((c+1)/2)-1,g=a[f];if(e>=b(g))break;a[f]=d,a[c]=g,c=f}}function e(a,b){if(a||(a=function(a){return a}),b||(b=function(a,b){return a===b}),"function"!=typeof a)throw new Error('BinaryHeap([weightFunc][, compareFunc]): "weightFunc" must be a function!');if("function"!=typeof b)throw new Error('BinaryHeap([weightFunc][, compareFunc]): "compareFunc" must be a function!');this.weightFunc=a,this.compareFunc=b,this.heap=[]}var f=function(a,b,c){for(var d=a.length,e=a[c],f=b(e);;){var g=2*(c+1),h=g-1,i=null;if(d>h){var j=a[h],k=b(j);f>k&&(i=h)}if(d>g){var l=a[g],m=b(l);m<(null===i?f:b(a[h]))&&(i=g)}if(null===i)break;a[c]=a[i],a[i]=e,c=i}},g=e.prototype;g.push=function(a){this.heap.push(a),d(this.heap,this.weightFunc,this.heap.length-1)},g.peek=function(){return this.heap[0]},g.pop=function(){var a=this.heap[0],b=this.heap.pop();return this.heap.length>0&&(this.heap[0]=b,f(this.heap,this.weightFunc,0)),a},g.remove=function(a){for(var b=this.heap.length,c=0;b>c;c++)if(this.compareFunc(this.heap[c],a)){var e=this.heap[c],g=this.heap.pop();return c!==b-1&&(this.heap[c]=g,d(this.heap,this.weightFunc,c),f(this.heap,this.weightFunc,c)),e}return null},g.removeAll=function(){this.heap=[]},g.size=function(){return this.heap.length},a.exports=e}])})}])}); //# sourceMappingURL=cachefactory.min.map \ No newline at end of file diff --git a/dist/cachefactory.min.map b/dist/cachefactory.min.map index e7562c9..6f76045 100644 --- a/dist/cachefactory.min.map +++ b/dist/cachefactory.min.map @@ -1 +1 @@ -{"version":3,"file":"cachefactory.min.js","sources":["cachefactory.js"],"names":["root","factory","exports","module","define","amd","this","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","CacheFactory","cacheId","options","createCache","BinaryHeap","_Promise","window","Promise","e","utils","isNumber","val","isString","isObject","isFunction","fromJson","JSON","parse","equals","a","b","_keys","collection","keys","key","undefined","hasOwnProperty","push","_isPromiseLike","v","then","_stringifyNumber","number","toString","_keySet","keySet","defaults","capacity","Number","MAX_VALUE","maxAge","deleteOnExpire","onExpire","cacheFlushInterval","recycleFreq","storageMode","storageImpl","disabled","storagePrefix","storeOnResolve","storeOnReject","caches","Error","$$data","$$promises","$$storage","$$expiresHeap","x","expires","$$lruHeap","accessed","cache","$$id","destroy","clearInterval","$$cacheFlushIntervalId","$$recycleFreqId","removeAll","removeItem","$$prefix","disable","$$disabled","enable","get","_this","Array","isArray","_ret","values","forEach","value","item","itemJson","getItem","now","Date","getTime","remove","$$deleteOnExpire","$$onExpire","setItem","stringify","info","created","isExpired","$$maxAge","$$capacity","$$cacheFlushInterval","$$recycleFreq","$$storageMode","size","keysJson","kSet","i","length","put","_this2","$$storeOnResolve","$$storeOnReject","getHandler","store","isError","status","data","headers","statusText","reject","exists","peek","index","indexOf","splice","removeExpired","expired","expiredItem","pop","setCacheFlushInterval","self","setInterval","setCapacity","removed","setDeleteOnExpire","setRecycleFreq","setMaxAge","setOnExpire","setOptions","cacheOptions","strict","$$storagePrefix","setStorageMode","shouldReInsert","items","localStorage","sessionStorage","touch","_this3","k","opt","destroyAll","clearAll","removeExpiredFromAll","enableAll","disableAll","touchAll","bubbleUp","heap","weightFunc","n","element","weight","parentN","Math","floor","_parent","compareFunc","y","bubbleDown","node","nodeWeight","child2N","child1N","swap","child1","child1Weight","child2","child2Weight","BHProto","prototype","front","end"],"mappings":";;;;;;;;;;CASA,SAA2CA,EAAMC,GAC1B,gBAAZC,UAA0C,gBAAXC,QACxCA,OAAOD,QAAUD,IACQ,kBAAXG,SAAyBA,OAAOC,IAC9CD,OAAOH,GACmB,gBAAZC,SACdA,QAAsB,aAAID,IAE1BD,EAAmB,aAAIC,KACtBK,KAAM,WACT,MAAgB,UAAUC,GAKhB,QAASC,GAAoBC,GAG5B,GAAGC,EAAiBD,GACnB,MAAOC,GAAiBD,GAAUP,OAGnC,IAAIC,GAASO,EAAiBD,IAC7BP,WACAS,GAAIF,EACJG,QAAQ,EAUT,OANAL,GAAQE,GAAUI,KAAKV,EAAOD,QAASC,EAAQA,EAAOD,QAASM,GAG/DL,EAAOS,QAAS,EAGTT,EAAOD,QAvBf,GAAIQ,KAqCJ,OATAF,GAAoBM,EAAIP,EAGxBC,EAAoBO,EAAIL,EAGxBF,EAAoBQ,EAAI,GAGjBR,EAAoB,KAK/B,SAASL,EAAQD,EAASM,GAszB/B,QAASS,GAAaC,EAASC,GAC7B,MAAOC,GAAYF,EAASC,GArzB9B,GAAIE,GAAab,EAAoB,GACjCc,EAAW,IACf,KACEA,EAAWC,OAAOC,QAClB,MAAOC,IAET,GAAIC,IACFC,SAAU,SAAkBC,GAC1B,MAAsB,gBAARA,IAGhBC,SAAU,SAAkBD,GAC1B,MAAsB,gBAARA,IAGhBE,SAAU,SAAkBF,GAC1B,MAAe,QAARA,GAA+B,gBAARA,IAGhCG,WAAY,SAAoBH,GAC9B,MAAsB,kBAARA,IAGhBI,SAAU,SAAkBJ,GAC1B,MAAOK,MAAKC,MAAMN,IAGpBO,OAAQ,SAAgBC,EAAGC,GACzB,MAAOD,KAAMC,GAGfb,QAASF,GAGPgB,EAAQ,SAAeC,GACzB,GAAIC,MACAC,EAAMC,MACV,KAAKD,IAAOF,GACNA,EAAWI,eAAeF,IAC5BD,EAAKI,KAAKH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KnD,OAAS,IAG1DwE,EAAQ1D,KAAO,WACb,MAAOjI,MAAKsK,KAAK,IAGnBqB,EAAQnD,IAAM,WACZ,GAAIqD,GAAQ7L,KAAKsK,KAAK,GAClBwB,EAAM9L,KAAKsK,KAAK9B,KAKpB,OAJIxI,MAAKsK,KAAKnD,OAAS,IACrBnH,KAAKsK,KAAK,GAAKwB,EACfb,EAAWjL,KAAKsK,KAAMtK,KAAKuK,WAAY,IAElCsB,GAGTF,EAAQzF,OAAS,SAAUgF,GAEzB,IAAK,GADD/D,GAASnH,KAAKsK,KAAKnD,OACdD,EAAI,EAAOC,EAAJD,EAAYA,IAC1B,GAAIlH,KAAK+K,YAAY/K,KAAKsK,KAAKpD,GAAIgE,GAAO,CACxC,GAAIrC,GAAU7I,KAAKsK,KAAKpD,GACpB4E,EAAM9L,KAAKsK,KAAK9B,KAMpB,OALItB,KAAMC,EAAS,IACjBnH,KAAKsK,KAAKpD,GAAK4E,EACfzB,EAASrK,KAAKsK,KAAMtK,KAAKuK,WAAYrD,GACrC+D,EAAWjL,KAAKsK,KAAMtK,KAAKuK,WAAYrD,IAElC2B,EAGX,MAAO,OAGT8C,EAAQ7G,UAAY,WAClB9E,KAAKsK,SAGPqB,EAAQ5E,KAAO,WACb,MAAO/G,MAAKsK,KAAKnD,QAGnBtH,EAAOD,QAAUmB"} \ No newline at end of file +{"version":3,"sources":["cachefactory.js"],"names":["root","factory","exports","module","define","amd","this","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","CacheFactory","cacheId","options","createCache","BinaryHeap","_Promise","window","Promise","e","utils","isNumber","val","isString","isObject","isFunction","fromJson","JSON","parse","equals","a","b","_keys","collection","keys","key","undefined","hasOwnProperty","push","_isPromiseLike","v","then","_stringifyNumber","number","toString","_keySet","keySet","defaults","capacity","Number","MAX_VALUE","maxAge","deleteOnExpire","onExpire","cacheFlushInterval","recycleFreq","storageMode","storageImpl","disabled","storagePrefix","storeOnResolve","storeOnReject","caches","Error","$$data","$$promises","$$storage","$$expiresHeap","x","expires","$$lruHeap","accessed","cache","$$id","destroy","clearInterval","$$cacheFlushIntervalId","$$recycleFreqId","removeAll","removeItem","$$prefix","disable","$$disabled","enable","get","_this","Array","isArray","_ret","values","forEach","value","item","itemJson","getItem","now","Date","getTime","remove","$$deleteOnExpire","$$onExpire","setItem","stringify","info","created","isExpired","$$maxAge","$$capacity","$$cacheFlushInterval","$$recycleFreq","$$storageMode","size","keysJson","kSet","i","length","put","_this2","$$storeOnResolve","$$storeOnReject","getHandler","store","isError","status","data","headers","statusText","reject","exists","peek","index","indexOf","splice","removeExpired","expired","expiredItem","pop","setCacheFlushInterval","self","setInterval","setCapacity","removed","setDeleteOnExpire","setRecycleFreq","setMaxAge","setOnExpire","setOptions","cacheOptions","strict","$$storagePrefix","setStorageMode","shouldReInsert","items","localStorage","sessionStorage","touch","_this3","k","opt","destroyAll","clearAll","removeExpiredFromAll","enableAll","disableAll","touchAll","bubbleUp","heap","weightFunc","n","element","weight","parentN","Math","floor","_parent","compareFunc","y","bubbleDown","node","nodeWeight","child2N","child1N","swap","child1","child1Weight","child2","child2Weight","BHProto","prototype","front","end"],"mappings":";;;;;;;;;;CASA,SAA2CA,EAAMC,GAC1B,gBAAZC,UAA0C,gBAAXC,QACxCA,OAAOD,QAAUD,IACQ,kBAAXG,SAAyBA,OAAOC,IAC9CD,UAAWH,GACe,gBAAZC,SACdA,QAAsB,aAAID,IAE1BD,EAAmB,aAAIC,KACtBK,KAAM,WACT,MAAgB,UAAUC,GAKhB,QAASC,GAAoBC,GAG5B,GAAGC,EAAiBD,GACnB,MAAOC,GAAiBD,GAAUP,OAGnC,IAAIC,GAASO,EAAiBD,IAC7BP,WACAS,GAAIF,EACJG,QAAQ,EAUT,OANAL,GAAQE,GAAUI,KAAKV,EAAOD,QAASC,EAAQA,EAAOD,QAASM,GAG/DL,EAAOS,QAAS,EAGTT,EAAOD,QAvBf,GAAIQ,KAqCJ,OATAF,GAAoBM,EAAIP,EAGxBC,E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,KAAK9B,KAMpB,OALItB,KAAMC,EAAS,IACjBnH,KAAKsK,KAAKpD,GAAK4E,EACfzB,EAASrK,KAAKsK,KAAMtK,KAAKuK,WAAYrD,GACrC+D,EAAWjL,KAAKsK,KAAMtK,KAAKuK,WAAYrD,IAElC2B,EAGX,MAAO,OAGT8C,EAAQ7G,UAAY,WAClB9E,KAAKsK,SAGPqB,EAAQ5E,KAAO,WACb,MAAO/G,MAAKsK,KAAKnD,QAGnBtH,EAAOD,QAAUmB","file":"cachefactory.min.js"} \ No newline at end of file diff --git a/package.json b/package.json index f79b672..d8af782 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "cachefactory", "description": "CacheFactory is a very simple and useful cache for the browser.", - "version": "1.1.0", + "version": "1.2.0", "homepage": "http://jmdobry.github.io/cachefactory/", "main": "dist/cachefactory.js", "repository": { @@ -23,32 +23,32 @@ "cache" ], "devDependencies": { - "babel-core": "5.6.17", - "babel-loader": "5.3.1", - "chai": "3.0.0", - "es6-promise": "^2.3.0", + "babel-core": "5.8.25", + "babel-loader": "5.3.2", + "chai": "3.3.0", + "es6-promise": "3.0.2", "grunt": "0.4.5", "grunt-contrib-clean": "0.6.0", - "grunt-contrib-uglify": "0.9.1", + "grunt-contrib-uglify": "0.9.2", "grunt-contrib-watch": "0.6.1", - "grunt-karma": "0.11.2", - "grunt-karma-coveralls": "2.5.3", + "grunt-karma": "0.12.1", + "grunt-karma-coveralls": "2.5.4", "grunt-webpack": "1.0.11", "jit-grunt": "0.9.1", "jshint": "2.8.0", "jshint-loader": "0.8.3", - "karma": "0.12.37", + "karma": "0.13.10", "karma-chai": "0.1.0", - "karma-chrome-launcher": "0.2.0", - "karma-coverage": "0.4.2", + "karma-chrome-launcher": "0.2.1", + "karma-coverage": "0.5.2", "karma-firefox-launcher": "0.1.6", "karma-mocha": "0.2.0", - "karma-phantomjs-launcher": "^0.2.0", + "karma-phantomjs-launcher": "0.2.1", "karma-sinon": "1.0.4", - "mocha": "2.2.5", - "phantomjs": "^1.9.17", + "mocha": "2.3.3", + "phantomjs": "1.9.18", "time-grunt": "1.2.1", - "webpack-dev-server": "1.10.1" + "webpack-dev-server": "1.12.0" }, "scripts": { "test": "grunt test" diff --git a/src/index.js b/src/index.js index b555d76..d95edf4 100644 --- a/src/index.js +++ b/src/index.js @@ -220,7 +220,7 @@ let createCache = (cacheId, options) => { created: item.created, accessed: item.accessed, expires: item.expires, - isExpired: (new Date().getTime() - item.created) > this.$$maxAge + isExpired: (new Date().getTime() - item.created) > (item.maxAge || this.$$maxAge) }; } else { return undefined; @@ -233,7 +233,7 @@ let createCache = (cacheId, options) => { created: item.created, accessed: item.accessed, expires: item.expires, - isExpired: (new Date().getTime() - item.created) > this.$$maxAge + isExpired: (new Date().getTime() - item.created) > (item.maxAge || this.$$maxAge) }; } else { return undefined; @@ -333,8 +333,12 @@ let createCache = (cacheId, options) => { created: now, accessed: now }; + + if (options.maxAge) { + item.maxAge = options.maxAge; + } - item.expires = item.created + this.$$maxAge; + item.expires = item.created + (item.maxAge || this.$$maxAge); if ($$storage) { if (_isPromiseLike(item.value)) { @@ -568,7 +572,7 @@ let createCache = (cacheId, options) => { if (this.$$maxAge === Number.MAX_VALUE) { item.expires = Number.MAX_VALUE; } else { - item.expires = item.created + this.$$maxAge; + item.expires = item.created + (item.maxAge || this.$$maxAge); } $$expiresHeap.push({ key: key, @@ -584,7 +588,7 @@ let createCache = (cacheId, options) => { if (this.$$maxAge === Number.MAX_VALUE) { $$data[key].expires = Number.MAX_VALUE; } else { - $$data[key].expires = $$data[key].created + this.$$maxAge; + $$data[key].expires = $$data[key].created + ($$data[key].maxAge || this.$$maxAge); } $$expiresHeap.push($$data[key]); } @@ -714,20 +718,18 @@ let createCache = (cacheId, options) => { let shouldReInsert = false; let items = {}; - if (typeof this.$$storageMode === 'string' && this.$$storageMode !== storageMode) { - let keys = this.keys(); + let keys = this.keys(); - if (keys.length) { - for (var i = 0; i < keys.length; i++) { - items[keys[i]] = this.get(keys[i]); - } - for (i = 0; i < keys.length; i++) { - this.remove(keys[i]); - } - shouldReInsert = true; + if (keys.length) { + for (var i = 0; i < keys.length; i++) { + items[keys[i]] = this.get(keys[i]); } + for (i = 0; i < keys.length; i++) { + this.remove(keys[i]); + } + shouldReInsert = true; } - + this.$$storageMode = storageMode; if (storageImpl) { diff --git a/test/unit/Cache/index.put.test.js b/test/unit/Cache/index.put.test.js index bb5b467..3bd88d7 100644 --- a/test/unit/Cache/index.put.test.js +++ b/test/unit/Cache/index.put.test.js @@ -82,6 +82,21 @@ describe('Cache#put(key, value[, options])', function () { done(); }, 100); }); + it('should remove items if an item-specific maxAge is specified and deleteOnExpire is set to "aggressive".', function (done) { + var cache = TestCacheFactory('put-cache-8a', {maxAge: 1000, deleteOnExpire: 'aggressive', recycleFreq: 20}); + cache.put('item1', 'value1', { maxAge: 10 }); + cache.put('item2', 'value2'); + assert.equal(cache.get('item1'), 'value1'); + assert.equal(cache.get('item2'), 'value2'); + setTimeout(function () { + assert.isUndefined(cache.info('item1')); + assert.isUndefined(cache.get('item1')); + assert.isDefined(cache.info('item2')); + assert.isDefined(cache.get('item2')); + + done(); + }, 100); + }); it('should should lazy delete an item when maxAge is specified and deleteOnExpire is set to "passive".', function (done) { var cache = TestCacheFactory('put-cache-9', {maxAge: 10, deleteOnExpire: 'passive'}); cache.put('item1', 'value1');