use session storage for stats cache (bug 701696)
This commit is contained in:
Родитель
e1d85c67a9
Коммит
4de033a176
|
@ -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),
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
};
|
||||
};
|
||||
})();
|
||||
|
|
Загрузка…
Ссылка в новой задаче