@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.
Files changed (2) hide show
  1. package/dist/index.js +32 -24
  2. 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
- logger2.debug("QUERY_CACHE: Attempting direct cache query using queryIn()", {
874
- queryHash,
875
- query: JSON.stringify(query),
876
- locations: JSON.stringify(locations)
877
- });
878
- try {
879
- const directCachedItems = await cacheMap.queryIn(query, locations);
880
- if (directCachedItems && directCachedItems.length > 0) {
881
- logger2.debug("QUERY_CACHE: Direct cache query SUCCESS - Found items in item cache", {
882
- queryHash,
883
- itemCount: directCachedItems.length,
884
- itemKeys: directCachedItems.map((item) => JSON.stringify(item.key))
885
- });
886
- const itemKeys = directCachedItems.map((item) => item.key);
887
- await cacheMap.setQueryResult(queryHash, itemKeys);
888
- logger2.debug("QUERY_CACHE: Stored query result from direct cache hit", {
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
- itemKeyCount: itemKeys.length,
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
- } catch (error) {
898
- logger2.debug("QUERY_CACHE: Error querying cache directly, proceeding to API", {
905
+ } else {
906
+ logger2.debug("QUERY_CACHE: Skipping direct cache query for empty/all query - cannot trust completeness", {
899
907
  queryHash,
900
- error: error instanceof Error ? error.message : String(error)
908
+ query: JSON.stringify(query)
901
909
  });
902
910
  }
903
911
  logger2.debug("QUERY_CACHE: Fetching from API (cache miss or invalid)", {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fjell/cache",
3
3
  "description": "Cache for Fjell",
4
- "version": "4.7.44",
4
+ "version": "4.7.45",
5
5
  "keywords": [
6
6
  "cache",
7
7
  "fjell"