Skip to content

Commit

Permalink
Fixes #118. Fixes #120. Closes #121. Closes #117.
Browse files Browse the repository at this point in the history
Stable Version 3.1.0.
  • Loading branch information
jmdobry committed Jul 15, 2014
1 parent f9248b8 commit 61345c6
Show file tree
Hide file tree
Showing 9 changed files with 135 additions and 68 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
##### 3.1.0 15 July 2014

###### Backwards compatible API changes
- #117 - call to DSCacheFactory(...) produces JSHint warning (Added DSCacheFactory.createCache method)

###### Backwards compatible bug fixes
- #118 - dist/angular-cache.js doesn't end with a semicolon (Upgraded dependencies)
- #120 - How come the non minified version has minified code? (Upgraded dependencies)

##### 3.0.3 16 June 2014

###### Backwards compatible bug fixes
Expand Down
3 changes: 2 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ module.exports = function (grunt) {
options: {
report: 'min',
sourceMap: true,
sourceMapName: 'dist/angular-cache.min.map',
banner: '/**\n' +
'* @author Jason Dobry <[email protected]>\n' +
'* @file angular-cache.min.js\n' +
'* @version <%= pkg.version %> - Homepage <https://github.com/jmdobry/angular-cache>\n' +
'* @copyright (c) 2013 Jason Dobry <http://www.pseudobry.com>\n' +
'* @copyright (c) 2013-2014 Jason Dobry <http://www.pseudobry.com>\n' +
'* @license MIT <https://github.com/jmdobry/angular-cache/blob/master/LICENSE>\n' +
'*\n' +
'* @overview angular-cache is a very useful replacement for Angular\'s $cacheFactory.\n' +
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## angular-cache
__A very useful replacement for Angular's $cacheFactory.__

__Version:__ 3.0.3
__Version:__ 3.1.0

Documentation for 3.x.x can be found at [angular-data.pseudobry.com](http://angular-data.pseudobry.com).

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"author": "Jason Dobry",
"name": "angular-cache",
"description": "angular-cache is a very useful replacement for Angular's $cacheFactory.",
"version": "3.0.3",
"version": "3.1.0",
"homepage": "https://github.com/jmdobry/angular-cache",
"repository": {
"type": "git",
Expand Down
74 changes: 52 additions & 22 deletions dist/angular-cache.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* @author Jason Dobry <[email protected]>
* @file angular-cache.js
* @version 3.0.3 - Homepage <https://github.com/jmdobry/angular-cache>
* @copyright (c) 2013 Jason Dobry <http://www.pseudobry.com>
* @version 3.1.0 - Homepage <https://github.com/jmdobry/angular-cache>
* @copyright (c) 2013-2014 Jason Dobry <http://www.pseudobry.com>
* @license MIT <https://github.com/jmdobry/angular-cache/blob/master/LICENSE>
*
* @overview angular-cache is a very useful replacement for Angular's $cacheFactory.
Expand Down Expand Up @@ -852,7 +852,7 @@ DSCache.prototype.touch = function (key) {

module.exports = DSCache;

},{"../DSBinaryHeap":1,"../defaults":"XjryW+","./destroy":2,"./get":3,"./info":5,"./keySet":6,"./keys":7,"./put":8,"./remove":9,"./removeAll":10,"./removeExpired":11,"./setCacheFlushInterval":12,"./setCapacity":13,"./setDeleteOnExpire":14,"./setMaxAge":15,"./setOnExpire":16,"./setRecycleFreq":17}],5:[function(require,module,exports){
},{"../DSBinaryHeap":1,"../defaults":"kH9dpy","./destroy":2,"./get":3,"./info":5,"./keySet":6,"./keys":7,"./put":8,"./remove":9,"./removeAll":10,"./removeExpired":11,"./setCacheFlushInterval":12,"./setCapacity":13,"./setDeleteOnExpire":14,"./setMaxAge":15,"./setOnExpire":16,"./setRecycleFreq":17}],5:[function(require,module,exports){
/**
* @doc method
* @id DSCache.methods:info
Expand Down Expand Up @@ -1717,7 +1717,7 @@ module.exports = function setRecycleFreq(recycleFreq) {
},{}],18:[function(require,module,exports){
var defaults = require('../defaults'),
DSCache = require('../DSCache'),
version = '3.0.3';
version = '3.1.0';

/**
* @doc function
Expand Down Expand Up @@ -1773,6 +1773,21 @@ function DSCacheFactoryProvider() {
return keys;
}

function createCache(cacheId, options) {
if (cacheId in caches) {
throw angular.$$minErr('$cacheFactory')('iid', "CacheId '{0}' is already taken!", cacheId);
} else if (!angular.isString(cacheId)) {
throw angular.$$minErr('ng')('areq', 'Expected cacheId to be a string! Found: {0}.', typeof cacheId);
}

caches[cacheId] = new DSCache(cacheId, angular.extend({}, config, options));
caches[cacheId].destroy = function () {
this.constructor.prototype.destroy.call(this);
delete caches[this.$$id];
};
return caches[cacheId];
}

/**
* @doc function
* @id DSCacheFactory
Expand All @@ -1798,20 +1813,35 @@ function DSCacheFactoryProvider() {
* @returns {DSCache} New instance of DSCache.
*/
function DSCacheFactory(cacheId, options) {
if (cacheId in caches) {
throw angular.$$minErr('$cacheFactory')('iid', "CacheId '{0}' is already taken!", cacheId);
} else if (!angular.isString(cacheId)) {
throw angular.$$minErr('ng')('areq', 'Expected cacheId to be a string! Found: {0}.', typeof cacheId);
}

caches[cacheId] = new DSCache(cacheId, angular.extend({}, config, options));
caches[cacheId].destroy = function () {
this.constructor.prototype.destroy.call(this);
delete caches[this.$$id];
};
return caches[cacheId];
return createCache(cacheId, options);
}

/**
* @doc method
* @id DSCacheFactory.methods:createCache
* @name createCache
* @description
* Factory function that produces instances of `DSCache`.
*
* @param {string} cacheId The id of the new cache.
* @param {object} options Configuration options. Properties:
*
* - `{number=}` - `capacity` - Default: `Number.MAX_VALUE`
* - `{number=}` - `maxAge` - Default: `null`
* - `{number=}` - `deleteOnExpire` - Default: `none`
* - `{function=}` - `onExpire` - Default: `null`
* - `{number=}` - `cacheFlushInterval` - Default: `null`
* - `{number=}` - `recycleFreq` - Default: `1000`
* - `{number=}` - `deleteOnExpire` - Default: `null`
* - `{string=}` - `storageMode` - Default: `'none`
* - `{object=}` - `storageImpl` - Default: `null`
* - `{boolean=}` - `disabled` - Default: `false`
* - `{string=}` - `storagePrefix` - Default: `"angular-cache.caches."`
*
* @returns {DSCache} New instance of DSCache.
*/
DSCacheFactory.createCache = createCache;

DSCacheFactory.version = version;

/**
Expand Down Expand Up @@ -2039,9 +2069,9 @@ function DSCacheFactoryProvider() {

module.exports = DSCacheFactoryProvider;

},{"../DSCache":4,"../defaults":"XjryW+"}],"Defaults":[function(require,module,exports){
module.exports=require('XjryW+');
},{}],"XjryW+":[function(require,module,exports){
},{"../DSCache":4,"../defaults":"kH9dpy"}],"Defaults":[function(require,module,exports){
module.exports=require('kH9dpy');
},{}],"kH9dpy":[function(require,module,exports){
var defaults = {
/**
* @doc overview
Expand Down Expand Up @@ -2335,7 +2365,7 @@ module.exports = {
* @id angular-cache
* @name Overview
* @description
* __Version:__ 3.0.3
* __Version:__ 3.1.0
*
* ## Install
*
Expand All @@ -2355,7 +2385,7 @@ module.exports = {
* also consumable by Browserify and you should be able to `require('angular-cache')`. The `main` file is `src/index.js`.
*
* #### Manual download
* Download angular-cache.3.0.3.js from the [Releases](https://github.com/jmdobry/angular-cache/releases)
* Download angular-cache.3.1.0.js from the [Releases](https://github.com/jmdobry/angular-cache/releases)
* section of the angular-cache GitHub project.
*
* ## Load into Angular
Expand Down Expand Up @@ -2418,4 +2448,4 @@ module.exports = {
}
};

},{}]},{},[21])
},{}]},{},[21]);
6 changes: 3 additions & 3 deletions dist/angular-cache.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/angular-cache.min.map

Large diffs are not rendered by default.

51 changes: 24 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "angular-cache",
"description": "angular-cache is a very useful replacement for Angular's $cacheFactory.",
"version": "3.0.3",
"version": "3.1.0",
"homepage": "http://jmdobry.github.io/angular-cache",
"main": "src/index.js",
"repository": {
Expand All @@ -19,37 +19,34 @@
"url": "https://github.com/jmdobry/angular-cache/blob/master/LICENSE"
}
],
"postinstall": "node node_modules/bower/bin/bower install && node node_modules/grunt-cli/bin/grunt build",
"postinstall": "node node_modules/grunt-cli/bin/grunt build",
"devDependencies": {
"grunt": "~0.4.2",
"grunt-contrib-jshint": "~0.8.0",
"grunt": "^0.4.5",
"grunt-contrib-jshint": "^0.10.0",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-uglify": "~0.3.2",
"grunt-contrib-uglify": "^0.5.0",
"grunt-contrib-copy": "~0.5.0",
"karma": "~0.10.9",
"grunt-karma": "~0.6.2",
"grunt-cli": "~0.1.13",
"phantomjs": "~1.9.7-1",
"karma-script-launcher": "~0.1.0",
"karma-phantomjs-launcher": "~0.1.2",
"karma-chrome-launcher": "~0.1.2",
"karma-firefox-launcher": "~0.1.3",
"karma-coverage": "~0.1.2",
"time-grunt": "~0.2.9",
"load-grunt-tasks": "~0.3.0",
"grunt-karma-coveralls": "~2.3.0",
"sinon": "~1.8.2",
"karma-sinon": "~1.0.2",
"chai": "~1.9.0",
"karma-chai": "~0.1.0",
"mocha": "~1.17.1",
"karma-mocha": "~0.1.1",
"browserify": "~3.30.1",
"grunt-browserify": "~1.3.1",
"bower": "~1.2.8",
"grunt-contrib-watch": "~0.5.3",
"time-grunt": "^0.4.0",
"load-grunt-tasks": "^0.6.0",
"sinon": "^1.10.3",
"chai": "^1.9.1",
"mocha": "^1.20.1",
"grunt-contrib-watch": "^0.6.1",
"grunt-docular": "~0.1.2",
"grunt-contrib-concat": "~0.3.0"
"grunt-contrib-concat": "^0.4.0",
"grunt-browserify": "^2.1.3",
"karma": "^0.12.17",
"grunt-karma": "^0.8.3",
"karma-chrome-launcher": "^0.1.4",
"karma-sinon": "^1.0.3",
"karma-script-launcher": "^0.1.0",
"karma-mocha": "^0.1.4",
"karma-firefox-launcher": "^0.1.3",
"karma-chai": "^0.1.0",
"grunt-karma-coveralls": "^2.5.1",
"karma-coverage": "^0.2.4",
"karma-phantomjs-launcher": "^0.1.4"
},
"scripts": {
"test": "node node_modules/grunt-cli/bin/grunt test",
Expand Down
54 changes: 42 additions & 12 deletions src/DSCacheFactory/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,21 @@ function DSCacheFactoryProvider() {
return keys;
}

function createCache(cacheId, options) {
if (cacheId in caches) {
throw angular.$$minErr('$cacheFactory')('iid', "CacheId '{0}' is already taken!", cacheId);
} else if (!angular.isString(cacheId)) {
throw angular.$$minErr('ng')('areq', 'Expected cacheId to be a string! Found: {0}.', typeof cacheId);
}

caches[cacheId] = new DSCache(cacheId, angular.extend({}, config, options));
caches[cacheId].destroy = function () {
this.constructor.prototype.destroy.call(this);
delete caches[this.$$id];
};
return caches[cacheId];
}

/**
* @doc function
* @id DSCacheFactory
Expand All @@ -81,20 +96,35 @@ function DSCacheFactoryProvider() {
* @returns {DSCache} New instance of DSCache.
*/
function DSCacheFactory(cacheId, options) {
if (cacheId in caches) {
throw angular.$$minErr('$cacheFactory')('iid', "CacheId '{0}' is already taken!", cacheId);
} else if (!angular.isString(cacheId)) {
throw angular.$$minErr('ng')('areq', 'Expected cacheId to be a string! Found: {0}.', typeof cacheId);
}

caches[cacheId] = new DSCache(cacheId, angular.extend({}, config, options));
caches[cacheId].destroy = function () {
this.constructor.prototype.destroy.call(this);
delete caches[this.$$id];
};
return caches[cacheId];
return createCache(cacheId, options);
}

/**
* @doc method
* @id DSCacheFactory.methods:createCache
* @name createCache
* @description
* Factory function that produces instances of `DSCache`.
*
* @param {string} cacheId The id of the new cache.
* @param {object} options Configuration options. Properties:
*
* - `{number=}` - `capacity` - Default: `Number.MAX_VALUE`
* - `{number=}` - `maxAge` - Default: `null`
* - `{number=}` - `deleteOnExpire` - Default: `none`
* - `{function=}` - `onExpire` - Default: `null`
* - `{number=}` - `cacheFlushInterval` - Default: `null`
* - `{number=}` - `recycleFreq` - Default: `1000`
* - `{number=}` - `deleteOnExpire` - Default: `null`
* - `{string=}` - `storageMode` - Default: `'none`
* - `{object=}` - `storageImpl` - Default: `null`
* - `{boolean=}` - `disabled` - Default: `false`
* - `{string=}` - `storagePrefix` - Default: `"angular-cache.caches."`
*
* @returns {DSCache} New instance of DSCache.
*/
DSCacheFactory.createCache = createCache;

DSCacheFactory.version = version;

/**
Expand Down

0 comments on commit 61345c6

Please sign in to comment.