Using querybuilder to retrieve pages and components to build json responses in servlets is very slow (seconds). The obvious solution is for us to cache all the required pages components properties, and just read off the required page properties from cache. Usually you would use distributed memory cache such as memcached, or an external cache such as redis.
Does AEM have anything like this out of the box?
If we setup memcached, presumably it will have to one perinstance, and not distributed. This will make manual flushing difficult. If we use external cache, such as redis, then this will be slower as we cant host redis in the same DC as AEM cloud (As we don't know here they are hosted) so latency will again be an issue.
The use case is recent / favourite games. If we have say 500 game pages, each with several components with properties such as category, image, description etc. We would get a list of recent game IDs from the server, then need to lookup up each page with the correspoding game ID or code, then look up the required components on that page, in order to display thumbnails and short text etc. Given the slow speed of querybuilder, we could cache the pages and their properties in memory for quick lookup, and then refresh the pages every 5 minutes or similar in case they get edited by content editor (a flush feature would be nice, but would have to flush all cloud instances which is presumably hard)
You can try for EhCache which caches the object at the JVM level. Please see more details below:
I'm not sure if I understand your use case 100% correct.
I'll just leave some general advice with regards to caching.
When working with AEM, you can leverage several levels of caching:
Please also bear in mind that caching is easy but correct cache invalidation is hard (some even say it's impossible). 😉
Hope that helps!