-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement optional caching #19
base: main
Are you sure you want to change the base?
Conversation
Introduced caching functionality using Caffeine for entity repositories, with configuration options for expiration, size, and other settings. Added a `@UseCache` annotation to enable caching for specific entities and ensured proper cache flushing during plugin shutdown.
Hello, thank you very much for your PR ! Here are some random thought and stuff we can improve concerning this implementation:
If I have time in the future, I can also help to address the above points |
Thank you for your reply! I will address these comments shortly. |
Hey, I am working on point 1 right now. I have a question about point 3; what parameters should be added to the use cache? Should the optional parameters be reflective of the config values? (Or something else) |
…me. Associate plugin name with entity class for dynamic unloading when calling the shutdown.
This scans the stack trace during the shutdown call and identifies entities associated with the plugin's name. I tested it with two different plugins, and it successfully removes the entities from the repository cache as each plugin invokes the shutdown() method. |
This PR implements a caching system that users can enable, which caches the objects before entering the database. This improves the querying performance of the library. To enable the cache, users have to:
@UseCache
The cache is powered by caffeine, a high-performance java caching library (https://github.com/ben-manes/caffeine)
It makes use of their
AsyncLoadingCache
to run most operations on the async executor.Due to how Bukkit unloads classes on shutdown, the user must call the api shutdown, as their plugin will be unloaded before NDatabase is unloaded.