mblinks: make expiration optional

Use a common default value of 90 days.
This commit is contained in:
Laurent Monin 2015-06-16 09:14:07 +02:00
parent 3d1f09cb89
commit bfe25c7da5
4 changed files with 5 additions and 5 deletions

View file

@ -204,7 +204,7 @@ var BandcampImport = {
$(document).ready(function () {
MBImportStyle();
var mblinks = new MBLinks('BCI_MBLINKS_CACHE', 7*24*60); // force refresh of cached links once a week
var mblinks = new MBLinks('BCI_MBLINKS_CACHE');
var release = BandcampImport.retrieveReleaseInfo();
LOGGER.info("Parsed release: ", release);

View file

@ -37,7 +37,7 @@ if (DEBUG) {
* - http://www.discogs.com/release/1566223 : Artist credit of tracks contains an ending ',' join phrase
*/
var mblinks = new MBLinks('DISCOGS_MBLINKS_CACHE', 7*24*60, '1'); // force refresh of cached links once a week
var mblinks = new MBLinks('DISCOGS_MBLINKS_CACHE', false, '1');
$(document).ready(function(){

View file

@ -14,7 +14,7 @@
// @require lib/mbimportstyle.js
// ==/UserScript==
var mblinks = new MBLinks('ENCYLOPEDISQUE_MBLINKS_CACHE', 7*24*60); // force refresh of cached links once a week
var mblinks = new MBLinks('ENCYLOPEDISQUE_MBLINKS_CACHE');
$(document).ready(function() {
MBImportStyle();

View file

@ -14,7 +14,7 @@
// }
// user_cache_key = textual key used to store cached data in local storage
// expiration = time in minutes before an entry is refreshed, value <= 0 disables cache reads
// expiration = time in minutes before an entry is refreshed, value <= 0 disables cache reads, if undefined or false, use defaults
// version = optionnal version, to force creation of a cache (ie. when format of keys changes)
var MBLinks = function (user_cache_key, expiration, version) {
this.supports_local_storage = function () {
@ -57,7 +57,7 @@ var MBLinks = function (user_cache_key, expiration, version) {
}
};
this.cache = {};
this.expirationMinutes = parseInt(expiration, 10);
this.expirationMinutes = ((typeof expiration != 'undefined' && expiration !== false) ? parseInt(expiration, 10) : 90*24*60); // default to 90 days
var cache_version = 2;
this.user_cache_key = user_cache_key;
this.cache_key = this.user_cache_key + '-v' + cache_version + (typeof version != 'undefined' ? '.' + version : '');