aboutsummaryrefslogtreecommitdiffstats
path: root/app/services/cache.service.js
blob: 291f0156ac91aebd8ba82964fef07323a0b52149 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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;
            };

        });

})();