Description
memcached, by default, only caches objects under 1 MB in size. In our current caching code, attempts to cache larger objects will fail silently. As a result, we are not getting the maximum benefit of memcached. We should:
- Check the size before caching.
- If it is over a certain threshold, apply a compression algorithm before submitting it to memcached.
- Tag the cached item to indicate that it was compressed.
- Arrange to uncompress it whenever it is retrieved from the cache.
- Check for failures when adding or updating an object in the cache, and log them for further analysis.
This is not the only strategy for dealing with oversized objects, but appears to be the best way to go based on investigation and conversations to date. (For one thing, arranging to increase the size limit has significant disadvantages.)
Desired behavior/Acceptance criteria (returned value, expected error, performance expectations, etc.)
- Objects of all sizes should successfully be cached, Unless they are so large that their compressed size is greater than 1 MB, in which case the failure should be logged.
Completion checklist
- Before closing this task, review one by one the checklist available here: https://www.mediawiki.org/wiki/Abstract_Wikipedia_team/Definition_of_Done#Back-end_Task/Bug_completion_checklist