INNER CODE UNIT · TypeScript
staleRefs
open-source-labs/obsidian · src/invalidateCacheCheck.ts:79
const staleRefs: Array<string> = mutationTableMap[mutationType]; // Grabs array of affected data tables from dev specified mutationTableMap
const rootQueryContents = await scope.cache.redis.hgetall('ROOT_QUERY'); // Creates array of all query keys and values in ROOT_QUERY from Redis
for (let j = 0; j < staleRefs.length; j++) { // Checks for all query keys that refer to the affected tables and deletes them from Redis
for (let i = 0; i < rootQueryContents.length; i += 2) {
if (
staleRefs[j] === rootQueryContents[i].slice(0, staleRefs[j].length)
) {
scope.cache.redis.hdel('ROOT_QUERY', rootQueryContents[i]);
}
}
}
}
await scope.cache.cacheWriteObject(redisKey, normalizedData); // Adds or updates reference in redis cache
}
}
}