I would like to get some recommendations on which cache to use for a user backend using SQL. I haven’t had any experience in this subject, yet.
I saw that \OC\User\Database
uses \OC\Cache\CappedMemoryCache
.
- Is this “still” a good (best) cache to use? Or would you recommend to use a 3d party library?
- Should I even use it from an app, although it is not in the public namespace (
\OCP
)?
- What are properties that are called very often and I should definitely cache? I think
userExists()
gets called a lot.
- What methods should not use the cache?
checkPassword()
maybe?
Any tips would be very welcome.
Some insights I gained during profiling
- My user backend app gets constructed and destroyed 6 times during a simple user login and no further interaction.
- There is nothing I can do about this, since this is out of control of the app.
- During one single life span of the app queries are made only once for the same user.
- A cache would not be used anyway
- I don’t see any way to predict what would be called next
- Possible optimization would be to retrieve the complete user record and then cache that single current user with a simple array.
–> My conclusion therefore is that the benefit of using a cache for user backends is negligible. Caveat: I only tested a few use cases.
Feedback is welcome, of course.