Skip to content

Commit

Permalink
feat(Cache): add records to cache during login if total records is be…
Browse files Browse the repository at this point in the history
…low the max
  • Loading branch information
cooldogedev committed Oct 20, 2023
1 parent 4b6748c commit 01657f9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/cooldogedev/BedrockEconomy/EventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,16 @@ function () use ($networkSession, $playerInfo): Generator {
decimals: $data["decimals"],
position: $data["position"],
));

if (count(GlobalCache::TOP()->getAll()) < $this->plugin->getConfig()->getNested("cache.rich-rows")) {
GlobalCache::TOP()->set($playerInfo->getUsername(), new CacheEntry(
amount: $data["amount"],
decimals: $data["decimals"],
position: $data["position"],
));
GlobalCache::TOP()->sort();
}

$this->plugin->getLogger()->debug("Loaded account for " . $playerInfo->getUsername() . " with balance of " . $data["amount"] . " and decimals of " . $data["decimals"]);
}
);
Expand Down

0 comments on commit 01657f9

Please sign in to comment.