Skip to content

Feat/currency placeholder and local caching - #23

Merged
ammodev merged 5 commits into
version/26.1from
feat/currency-placeholder-and-local-caching
Oct 7, 2026
Merged

ammodev merged 5 commits into
version/26.1from
feat/currency-placeholder-and-local-caching

Conversation

@TheBjoRedCraft

Copy link
Copy Markdown
Contributor

No description provided.

@TheBjoRedCraft TheBjoRedCraft self-assigned this Oct 6, 2026
Copilot AI balanced review requested due to automatic review settings October 6, 2026 07:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

It adds concurrency-sensitive caching with cross-node Redis invalidation on the money/balance path, with no tests in the affected modules, so final human review is warranted.

Review effort: Balanced
Findings: None

What changed in this PR

This PR adds locally-cached, non-suspending balance reads for the client runtime and exposes them through PlaceholderAPI on Paper. A new BalanceCache keeps per-default-account balances in a Caffeine cache that is never recomputed locally; instead, whenever a transaction touches an account the balance is re-queried from the microservice. Cross-node consistency is achieved by publishing a BalanceChangedEvent over Redis so other servers refresh their cached entries, while the originating server refreshes locally and skips its own event. Three PAPI placeholders (current-balance, current-balance-short, currency-display) surface this data in-game.

Changes:

  • Introduce BalanceCache (background-loaded, versioned, event-invalidated) and wire TransactionServiceImpl to invalidate it on every balance-changing operation (begin/commit/rollback/deposit/withdraw/transfer).
  • Add BalanceChangedEvent + BalanceEventsListener and register the listener in RedisService; dispose the cache scope on client shutdown.
  • Add PAPI placeholders and expansion, registered from PaperMain; bump Gradle wrapper to 9.8.0 and project version to 4.1.8.
File Description
.../​balance/​BalanceCache.kt New non-suspending balance cache with background loading, versioned refresh, and Redis-based invalidation.
.../​transaction/​TransactionServiceImpl.kt Invalidates BalanceCache on all balance-changing results via per-result-type transactions extensions.
.../​redis/​events/​balance/​BalanceChangedEvent.kt New serializable Redis event carrying affected account IDs and currency name.
.../​balance/​BalanceEventsListener.kt Refreshes cached balances on remote BalanceChangedEvent, skipping self-originated events.
.../​redis/​RedisService.kt Subscribes the new BalanceEventsListener.
.../​client/​ClientTransactionalInstance.kt Disposes the BalanceCache scope on client disable.
.../​papi/​placeholder/​CurrentBalancePlaceholder.kt PAPI placeholder returning the full-precision cached balance.
.../​papi/​placeholder/​CurrentBalanceShortPlaceholder.kt PAPI placeholder returning the cached balance rounded to 2 decimals.
.../​papi/​placeholder/​CurrencyDisplayPlaceholder.kt PAPI placeholder returning a currency symbol.
.../​papi/​PapiExpansion.kt Aggregates the placeholders into a PAPI expansion.
.../​paper/​PaperMain.kt Registers the PAPI expansion on enable.
gradle/​wrapper/​gradle-wrapper.properties, gradle.properties Gradle wrapper 9.8.0 and project version 4.1.8 bumps.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@ammodev
ammodev merged commit c9d9865 into version/26.1 Oct 7, 2026
1 check passed
@ammodev
ammodev deleted the feat/currency-placeholder-and-local-caching branch October 7, 2026 15:20
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.

3 participants