INNER CODE UNIT · TypeScript

invalidateCache

open-source-labs/obsidian · src/invalidateCacheCheck.ts:49

export async function invalidateCache(
  normalizedMutation: { [key: string]: object },
  queryString: string,
  mutationTableMap: Record<string, unknown>
) {
  let normalizedData: object;
  let cachedVal: any;

  // Common case is that we get one mutation at a time. But it's possible to group multiple mutation queries into one.
  // That's why the for loop is needed
  for (const redisKey in normalizedMutation) {
    normalizedData = normalizedMutation[redisKey];
    cachedVal = await scope.cache.cacheReadObject(redisKey);

    // if response objects from mutation and cache are deeply equal then we delete it from cache because it infers that it's a delete mutation
    if (
      (cachedVal !== undefined && deepEqual(normalizedData, cachedVal)) ||
      isDelete(queryString)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…