view js/modules/cache.js @ 66:55c1b3647357

cache now uses localstorage
author Atul Varma <avarma@mozilla.com>
date Sun, 25 Apr 2010 09:10:46 -0700
parents 0b71df72ebe1
children 312d4af344c2
line wrap: on
line source

Require.modules["cache"] = function(exports, require) {
  var window = require("window");
  var cache;

  if (window.localStorage["cache"]) {
    cache = JSON.parse(window.localStorage["cache"]);
  } else
    cache = {};

  exports.set = function set(key, value) {
    cache[key] = value;
    window.localStorage["cache"] = JSON.stringify(cache);
  };
  exports.get = function get(key) {
    return cache[key];
  };
};