nette/caching

Maybe we can consider adding a solution to the problem of cache stampede

wf58585858 opened this issue · 1 comments

In a high-concurrency system, at the moment of cache failure, a large number of requests will enter the database, which can easily cause the database to crash

reference:
https://www.wikiwand.com/en/Cache_stampede
https://symfony.com/doc/current/components/cache.html

Hi,

  1. Locking - although it is not mentioned in documentation, if you use a second argument of load - generator callback, it actually uses a lock (if the storage supports locks - afaik redis does not support native locks and they must be emulated in some way).
  2. External recomputation - this could (and should) be solved in a userland
  3. Probabilistic early expiration - i like this idea