diff 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 diff
--- a/js/modules/cache.js	Sun Apr 25 08:52:28 2010 -0700
+++ b/js/modules/cache.js	Sun Apr 25 09:10:46 2010 -0700
@@ -1,8 +1,15 @@
-Require.modules["cache"] = function(exports) {
-  var cache = {};
+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];