var angular = require('angular');
require('../modules');
require('./CacheFactory');
var module = angular.module('commons.services');

module.factory('MemStorage', function() {
  var map = {};
  return {
    getItem: function(key) {
      return map[key];
    },
    setItem: function(key, value) {
      map[key] = value;
      return value;
    },
    removeItem: function(key) {
      var value = map[key];
      delete map[key];
      return value;
    }
  };
});

module.factory('MemCache', function(MemStorage, CacheFactory) {
  return CacheFactory.generate(MemStorage);
});
