Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/lib/actions/search-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,13 @@ export const getLocationSuggestions = unstable_cache(
}
},
["location-suggestions"],
{ revalidate: 3600 } // Cache for 1 hour
// Tagged with LISTINGS_TAG so the existing updateTag("listings") calls
// in listing-actions.ts (create/update/publish/unpublish/delete) bust
// the autocomplete cache too. Without this, autocomplete kept serving
// pre-mutation results for up to an hour — a deploy that introduced
// pg_trgm errors had its empty results cached, and that empty cache
// outlived the migration fix.
{ revalidate: 3600, tags: [LISTINGS_TAG] }
);

/**
Expand All @@ -129,7 +135,9 @@ export const getLocationSuggestions = unstable_cache(
* Previously fetched the entire Location table and dedup'd in JS, which
* scaled linearly with row count.
*
* Cached for 1 hour.
* Cached for 1 hour. Tagged with LISTINGS_TAG so listing mutations
* invalidate it (the popular-cities ranking changes whenever a listing
* is added or removed in a city).
*/
export const getPopularLocations = unstable_cache(
async (
Expand All @@ -151,7 +159,7 @@ export const getPopularLocations = unstable_cache(
}
},
["popular-locations"],
{ revalidate: 3600 } // Cache for 1 hour
{ revalidate: 3600, tags: [LISTINGS_TAG] }
);

/**
Expand Down
Loading