MCPcopy Create free account
hub / github.com/violentmonkey/violentmonkey / get

Function get

src/background/utils/storage-cache.js:47–73  ·  view source on GitHub ↗
(keys)

Source from the content-addressed store, hash-verified

45export const cachedStorageApi = storage.api = {
46
47 async get(keys) {
48 const res = {};
49 cache.batch(true);
50 keys = keys?.filter(key => {
51 const cached = cache.get(key);
52 const ok = cached !== undefined;
53 if (ok) res[key] = deepCopy(cached);
54 return !ok && dbKeys.get(key) !== 0;
55 });
56 if (!keys || keys.length) {
57 let lifetime, id;
58 if (!keys) lifetime = TTL_SKIM; // DANGER! Must be `undefined` otherwise.
59 (await api.get(keys))::forEachEntry(([key, val]) => {
60 res[key] = val;
61 dbKeys.set(key, 1);
62 cache.put(key, deepCopy(val), lifetime);
63 if (key.startsWith(S_SCRIPT_PRE)) {
64 updateScriptMap(key, val);
65 } else if (key.startsWith(S_MOD_PRE) && (id = +key.slice(S_MOD_PRE.length))) {
66 scriptSiteVisited[id] = val;
67 }
68 });
69 keys?.forEach(key => !hasOwnProperty(res, key) && dbKeys.set(key, 0));
70 }
71 cache.batch(false);
72 return res;
73 },
74
75 async set(data, flushNow) {
76 const toWrite = {};

Callers

nothing calls this directly

Calls 4

updateScriptMapFunction · 0.90
filterMethod · 0.80
setMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected