Skip to content

Reload points cache off the main thread - #91

Open
GG-MD wants to merge 1 commit into
Rosewood-Development:masterfrom
GG-MD:fix/async-points-cache-refresh
Open

Reload points cache off the main thread#91
GG-MD wants to merge 1 commit into
Rosewood-Development:masterfrom
GG-MD:fix/async-points-cache-refresh

Conversation

@GG-MD

@GG-MD GG-MD commented Aug 9, 2026

Copy link
Copy Markdown

The Guava points cache uses refreshAfterWrite, but Guava's default reload runs
synchronously on the calling thread. So every ~30s a give/take on an
online player triggers a blocking SQLite query on the main server thread - spark
showed ~276ms stalls parked on the SQLite connection monitor.

Wrapped the CacheLoader in CacheLoader.asyncReloading(...), running refreshes
on the plugin's async scheduler instead. Stale entries are returned immediately
and refreshed in the background - no more tick stalls.

Balance correctness is unaffected: Guava drops the stale reload result if a
put landed while it was running, and pending transactions are layered on top
in getEffectivePoints() regardless.

Note: this only covers refresh of already-cached entries. A cold cache
miss (offline player, or an entry evicted after 5 min) still loads synchronously

  • same as before, out of scope here.

@GG-MD

GG-MD commented Aug 9, 2026

Copy link
Copy Markdown
Author

@Esophose

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