chore(cache): counter cache storage using Redis
Context
This is related to Download counter for container images (&14021) and proposed implementation plan.
Problem
The registry needs to store the number of times a container repository has been downloaded.
Proposal
Use Redis to stage bursts of increments (async, after dispatching the API response, likely with a new repository statistics middleware) and periodically flush the counter value to the database (also async). This gives us the best possible performance, scalability and reliability.
Notes:
- Invalidate cache when a repository is moved !1729 (comment 2087310742)
- Consider a sensible TTL to prevent stale keys
Edited by Jaime Martinez