Skip to content

fix: use LRU eviction for cron schedule cache instead of FIFO#137

Open
BingqingLyu wants to merge 2 commits into
mainfrom
fork-pr-39703-fix-cron-cache-lru-eviction
Open

fix: use LRU eviction for cron schedule cache instead of FIFO#137
BingqingLyu wants to merge 2 commits into
mainfrom
fork-pr-39703-fix-cron-cache-lru-eviction

Conversation

@BingqingLyu

@BingqingLyu BingqingLyu commented Apr 27, 2026

Copy link
Copy Markdown
Owner

Summary

  • On cache hit in resolveCachedCron(), delete and re-set the entry to move it to the end of Map iteration order
  • This gives true LRU eviction instead of FIFO, preventing frequently-accessed cron expressions (e.g. */5 * * * * heartbeats) from being evicted prematurely
  • Added test verifying that accessed entries survive eviction after cache fills

Test plan

  • Existing 22 tests pass
  • New LRU promotion test added and passing
  • pnpm build && pnpm check && pnpm test all green

Fixes openclaw#39679

🤖 Generated with Claude Code

Bortlesboat and others added 2 commits March 8, 2026 06:06
On cache hit, delete and re-set the entry to move it to the end of
Map iteration order. This prevents frequently-accessed cron expressions
(e.g. heartbeat schedules) from being evicted prematurely while
rarely-used entries persist.

Fixes openclaw#39679

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add hasCronInCacheForTest helper and assert specific cache entries
survive or get evicted. The test now fails under FIFO but passes
under LRU, directly verifying the promotion behavior.
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.

[Bug] Cron schedule cache eviction is FIFO, not LRU — hot entries get evicted prematurely

2 participants