@fjell/cache 4.7.44 → 4.7.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +32 -24
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -870,34 +870,42 @@ async function executeAllLogic(query, locations, context) {
|
|
|
870
870
|
} else {
|
|
871
871
|
logger2.debug("QUERY_CACHE: Cache MISS - No cached query result found", { queryHash });
|
|
872
872
|
}
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
873
|
+
const isEmptyQuery = Object.keys(query).length === 0 || (Object.keys(query).length === 1 && "limit" in query || "offset" in query);
|
|
874
|
+
if (!isEmptyQuery) {
|
|
875
|
+
logger2.debug("QUERY_CACHE: Attempting direct cache query using queryIn() for filtered query", {
|
|
876
|
+
queryHash,
|
|
877
|
+
query: JSON.stringify(query),
|
|
878
|
+
locations: JSON.stringify(locations)
|
|
879
|
+
});
|
|
880
|
+
try {
|
|
881
|
+
const directCachedItems = await cacheMap.queryIn(query, locations);
|
|
882
|
+
if (directCachedItems && directCachedItems.length > 0) {
|
|
883
|
+
logger2.debug("QUERY_CACHE: Direct cache query SUCCESS - Found items in item cache", {
|
|
884
|
+
queryHash,
|
|
885
|
+
itemCount: directCachedItems.length,
|
|
886
|
+
itemKeys: directCachedItems.map((item) => JSON.stringify(item.key))
|
|
887
|
+
});
|
|
888
|
+
const itemKeys = directCachedItems.map((item) => item.key);
|
|
889
|
+
await cacheMap.setQueryResult(queryHash, itemKeys);
|
|
890
|
+
logger2.debug("QUERY_CACHE: Stored query result from direct cache hit", {
|
|
891
|
+
queryHash,
|
|
892
|
+
itemKeyCount: itemKeys.length,
|
|
893
|
+
itemKeys: itemKeys.map((k) => JSON.stringify(k))
|
|
894
|
+
});
|
|
895
|
+
return directCachedItems;
|
|
896
|
+
} else {
|
|
897
|
+
logger2.debug("QUERY_CACHE: Direct cache query returned no items", { queryHash });
|
|
898
|
+
}
|
|
899
|
+
} catch (error) {
|
|
900
|
+
logger2.debug("QUERY_CACHE: Error querying cache directly, proceeding to API", {
|
|
889
901
|
queryHash,
|
|
890
|
-
|
|
891
|
-
itemKeys: itemKeys.map((k) => JSON.stringify(k))
|
|
902
|
+
error: error instanceof Error ? error.message : String(error)
|
|
892
903
|
});
|
|
893
|
-
return directCachedItems;
|
|
894
|
-
} else {
|
|
895
|
-
logger2.debug("QUERY_CACHE: Direct cache query returned no items", { queryHash });
|
|
896
904
|
}
|
|
897
|
-
}
|
|
898
|
-
logger2.debug("QUERY_CACHE:
|
|
905
|
+
} else {
|
|
906
|
+
logger2.debug("QUERY_CACHE: Skipping direct cache query for empty/all query - cannot trust completeness", {
|
|
899
907
|
queryHash,
|
|
900
|
-
|
|
908
|
+
query: JSON.stringify(query)
|
|
901
909
|
});
|
|
902
910
|
}
|
|
903
911
|
logger2.debug("QUERY_CACHE: Fetching from API (cache miss or invalid)", {
|