improve: optimization of new shop (store)#1159
Merged
mehah merged 1 commit intoopentibiabr:mainfrom May 19, 2025
Merged
Conversation
The main improvements implemented in the code are: >> Cache System for Points: * Added a cache system to reduce frequent database queries. * The cache expires after 5 minutes to ensure that the data is updated periodically. >> Optimization of Infinite Loop: * Added a counter to limit the number of executions of the refreshPlayersPoints function. * The counter is stored in GlobalStorage for persistence. >> Single Initialization of the Shop: * Implemented a check to prevent the shop from being initialized multiple times. * This reduces memory usage and redundant processing. >> String Construction Optimization: * Replaced excessive concatenations with table construction and table.concat(). * This approach is much more efficient in Lua. >> Event Consolidation: * Created a unified updatePlayerShopData function to reduce the number of event calls. * This reduces the overhead of scheduling events. >> Cache Cleanup on Logout: * Added a logout event to clear the cache when the player disconnects. * This prevents memory accumulation from data of players who are no longer online. >> Purchase History Limitation: * Limited the purchase history to 50 records to avoid data overload. >> Name Validation Optimization: * Improved the efficiency of the validName function by using lookup tables and more direct checks.
|
This is the fourth (from game_shop) commit in less than five days. Could you leave the PR open for at least a week? That way, you can introduce future changes or whatever you have planned within seven days, and then it can be merged into the branch. Just to keep the main repo commits cleaner. I hope my comment doesn't bother you. |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



The main improvements implemented in the code are:
Cache System for Points:
* Added a cache system to reduce frequent database queries.* The cache expires after 5 minutes to ensure that the data is updated periodically.
Optimization of Infinite Loop:
* Added a counter to limit the number of executions of the refreshPlayersPoints function.* The counter is stored in GlobalStorage for persistence.
Single Initialization of the Shop:
* Implemented a check to prevent the shop from being initialized multiple times.* This reduces memory usage and redundant processing.
String Construction Optimization:
* Replaced excessive concatenations with table construction and table.concat().* This approach is much more efficient in Lua.
Event Consolidation:
* Created a unified updatePlayerShopData function to reduce the number of event calls.* This reduces the overhead of scheduling events.
Cache Cleanup on Logout:
* Added a logout event to clear the cache when the player disconnects.* This prevents memory accumulation from data of players who are no longer online.
Purchase History Limitation:
* Limited the purchase history to 50 records to avoid data overload.Name Validation Optimization:
* Improved the efficiency of the validName function by using lookup tables and more direct checks.