diff options
Diffstat (limited to 'app/services/cache.service.js')
-rw-r--r-- | app/services/cache.service.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/app/services/cache.service.js b/app/services/cache.service.js new file mode 100644 index 0000000..291f015 --- /dev/null +++ b/app/services/cache.service.js @@ -0,0 +1,37 @@ +(function () { + + 'use strict'; + + angular + .module('dcaeApp.services.cacheService', []) + .service('cacheService', function () { + + var data = {}; + + this.get = function (key) { + return data[key]; + }; + + this.delete = function (key) { + return data[key] = undefined; + }; + + this.deleteAll = function () { + return data = {}; + }; + + this.set = function (key, value) { + if (data[key] === undefined) { + data[key] = value; + } else { + data[key] = $.extend({}, value, data[key]); + } + }; + + this.toString = function () { + return data; + }; + + }); + +})(); |