Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

Commit

Permalink
use session storage for stats cache (bug 701696)
Browse files Browse the repository at this point in the history
  • Loading branch information
potch committed Dec 14, 2011
1 parent e1d85c6 commit 4de033a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
4 changes: 2 additions & 2 deletions media/js/impala/stats/manager.js
Expand Up @@ -11,11 +11,11 @@ z.StatsManager = (function() {

// The version of the stats localStorage we are using.
// If you increment this number, you cache-bust everyone!
var STATS_VERSION = '2011-10-21-1';
var STATS_VERSION = '2011-12-12';
var PRECISION = 2;

var storage = z.Storage("stats"),
storageCache = z.Storage("statscache"),
storageCache = z.SessionStorage("statscache"),
dataStore = {},
currentView = {},
addonId = parseInt($(".primary").attr("data-addon_id"), 10),
Expand Down
29 changes: 29 additions & 0 deletions media/js/zamboni/storage.js
Expand Up @@ -44,3 +44,32 @@ z.Storage = (function() {
};
};
})();

z.SessionStorage = (function() {
var cookieStorage = {
getItem: function(key) {
return $.cookie(key);
},
setItem: function(key, value) {
return $.cookie(key, value, {path: '/'});
},
removeItem: function(key) {
return $.cookie(key, null);
}
};
var engine = z.capabilities.localStorage ? sessionStorage : cookieStorage;
return function(namespace) {
namespace = namespace ? namespace + '-' : '';
return {
get: function(key) {
return engine.getItem(namespace + key);
},
set: function(key, value) {
return engine.setItem(namespace + key, value);
},
remove: function(key) {
return engine.removeItem(namespace + key);
}
};
};
})();

0 comments on commit 4de033a

Please sign in to comment.