MCPcopy Create free account
hub / github.com/ampproject/amphtml / get

Method get

src/service/storage-impl.js:217–227  ·  view source on GitHub ↗

* @param {string} name * @param {number|undefined} opt_duration * @return {*|undefined}

(name, opt_duration)

Source from the content-addressed store, hash-verified

215 * @return {*|undefined}
216 */
217 get(name, opt_duration) {
218 // The structure is {key: {v: *, t: time}}
219 const item = this.values_[name];
220 const timestamp = item ? item['t'] : undefined;
221 const isNotExpired =
222 opt_duration && timestamp != undefined
223 ? timestamp + opt_duration > Date.now()
224 : true;
225 const value = item && isNotExpired ? item['v'] : undefined;
226 return value;
227 }
228
229 /**
230 * Set the storage value along with the current timestamp.

Callers 1

getMethod · 0.45

Calls 1

nowMethod · 0.80

Tested by

no test coverage detected