MCPcopy Index your code
hub / github.com/scality/cloudserver / shouldRefresh

Method shouldRefresh

lib/kms/Cache.js:44–53  ·  view source on GitHub ↗

* Determines if the cache should be refreshed based on the last checked time. * @param {number} duration - Duration in milliseconds for cache validity. * @returns {boolean} true if the cache should be refreshed, else false.

(duration = 1 * 60 * 60 * 1000)

Source from the content-addressed store, hash-verified

42 * @returns {boolean} true if the cache should be refreshed, else false.
43 */
44 shouldRefresh(duration = 1 * 60 * 60 * 1000) { // Default: 1 hour
45 if (!this.lastChecked) {
46 return true;
47 }
48
49 const now = Date.now();
50 const elapsed = now - this.lastChecked;
51 const jitter = Math.floor(Math.random() * 15 * 60 * 1000); // Up to 15 minutes
52 return elapsed > (duration - jitter);
53 }
54
55 /**
56 * Clears the cache.

Callers 2

checkHealthMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected