annotate js/modules/cache.js @ 71:4ec651cc606e

we now only make one request at a time to the bugzilla server, which reduces app responsiveness but makes us less of a douche to the server.
author Atul Varma <avarma@mozilla.com>
date Sun, 25 Apr 2010 17:55:54 -0700
parents 55c1b3647357
children 312d4af344c2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
66
55c1b3647357 cache now uses localstorage
Atul Varma <avarma@mozilla.com>
parents: 47
diff changeset
1 Require.modules["cache"] = function(exports, require) {
55c1b3647357 cache now uses localstorage
Atul Varma <avarma@mozilla.com>
parents: 47
diff changeset
2 var window = require("window");
55c1b3647357 cache now uses localstorage
Atul Varma <avarma@mozilla.com>
parents: 47
diff changeset
3 var cache;
55c1b3647357 cache now uses localstorage
Atul Varma <avarma@mozilla.com>
parents: 47
diff changeset
4
55c1b3647357 cache now uses localstorage
Atul Varma <avarma@mozilla.com>
parents: 47
diff changeset
5 if (window.localStorage["cache"]) {
55c1b3647357 cache now uses localstorage
Atul Varma <avarma@mozilla.com>
parents: 47
diff changeset
6 cache = JSON.parse(window.localStorage["cache"]);
55c1b3647357 cache now uses localstorage
Atul Varma <avarma@mozilla.com>
parents: 47
diff changeset
7 } else
55c1b3647357 cache now uses localstorage
Atul Varma <avarma@mozilla.com>
parents: 47
diff changeset
8 cache = {};
47
0b71df72ebe1 integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
diff changeset
9
0b71df72ebe1 integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
diff changeset
10 exports.set = function set(key, value) {
0b71df72ebe1 integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
diff changeset
11 cache[key] = value;
66
55c1b3647357 cache now uses localstorage
Atul Varma <avarma@mozilla.com>
parents: 47
diff changeset
12 window.localStorage["cache"] = JSON.stringify(cache);
47
0b71df72ebe1 integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
diff changeset
13 };
0b71df72ebe1 integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
diff changeset
14 exports.get = function get(key) {
0b71df72ebe1 integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
diff changeset
15 return cache[key];
0b71df72ebe1 integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
diff changeset
16 };
0b71df72ebe1 integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
diff changeset
17 };