Disabled cache lets run SQL commands on the main thread
games647 opened this issue ยท 2 comments
Background:
For inventory protection, we are checking every time the inventory is changed if the user is registered (If not logged in). In #2109 we found out that if caching is disabled this runs directly a database query on the main thread. Despite this being bad practice, this runs for every packet, so possible a lot of times and effect the performance very easily.
Solution:
This part is found at numerous places like event listeners, so the easy solution to just run it asynchronous is useless. In the configuration we recommend disable the cache for BungeeCord and website registration. This highlights why we cannot just let it enabled.
However in case of BungeeCord we already request refreshes on something like password changes to other servers using plugin messages, still currently not registering. For website registration we could periodically refresh the data or use something like Redis. We already do the first one every 5 minutes if caching is enabled. The best solution would be to have single task that refreshes it depending on a last updated timestamp for all players.
=> Ultimately we have to cache the result of a player not registered too.
What is your recommendation? Do I miss here something?
EDIT: Added using plugin messages and explained that 5 minute refresh is only activated when using the cache.
Sorry for reply this. So if i have only one BungeeCord environment and only one auth server (preLobby) can leave 'caching: true' ?
Sorry for reply this.
No need to. This is open for everyone.
So if i have only one BungeeCord environment and only one auth server (preLobby) can leave 'caching: true' ?
We recommend disabling the cache for always fetching the newest data. In this case, you theoretically can enable caching, because the newest data is already locally and it's the only source for modifications.