Consider registering API usage with the UserHousekeeper on user get
kezz opened this issue · 2 comments
Description
At the moment, users obtained through the API (that aren't online) are discarded regardless of how often or frequently they are accessed. This means that unnecessary storage calls could be being fired repeatedly.
Proposed behaviour
In order to prevent User
instances that are in active use by plugins/mods from being expired, the UserHousekeeper
method registerApiUser
could be touched on get
calls in addition to load
calls.
This would mean that the 5 minute expiry timer will only trigger after a plugin has not accessed a user through the UserManager
after 5 minutes, similar to how cached data expiry is managed.
Alternatively, exposing a method to the API that would allow plugins to reset this expiry time manually would also solve this issue by allowing plugins that know they are going to obtain a user frequently to note that they do not wish it to be cleaned up by the housekeeper.
Additionally, allowing the API usage cache timeout to be configurable could allow for more fine tuning regarding how long data is kept, but would still not solve the root problem this issue represents.
I've implemented your first suggested fix in the commit above. If that doesn't resolve the problem fully then let me know and we can consider further changes. :)