Skip to content

feat: add in-memory cache for recently seen aircraft#126

Merged
tomcarman merged 2 commits into
devfrom
add-cache-for-recently-seen
May 5, 2026
Merged

feat: add in-memory cache for recently seen aircraft#126
tomcarman merged 2 commits into
devfrom
add-cache-for-recently-seen

Conversation

@tomcarman
Copy link
Copy Markdown
Owner

  • Previously, the query in getAircraftRecentlySeen() was running every tick/2s, and querying every hex currently in range.
  • As the main aircraft_data table has grown, aircraft have been seen many times, so lots of rows were getting loaded, before finally filtered again to get the most recent occurrence of each hex.
  • This was leading to huge CPU spikes - slow query, being done every 2s.
  • It was also a bit stupid, because the app knows what aircraft its recently seen, as they were in the last aircraft.json. Only "new" aircraft need to be checked (in case they had been dropped / re-entered).
  • The recently seen aircraft are now cached in memory - this means the query only runs when "new" aircraft are seen, and it only runs against those particular hexes (making it faster)
  • tldr; recently seen query runs less and faster.

@tomcarman tomcarman merged commit 5a3db78 into dev May 5, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant