apcu icon indicating copy to clipboard operation
apcu copied to clipboard

Ideas for improving apcu_entry()

Open nicolas-grekas opened this issue 6 years ago • 0 comments

Hello, while working on stampede protection for a future version of Symfony Cache, I wanted to share two ideas that might improve the behavior of apcu_entry():

  1. the $ttl value might not be known at fetch-time. It would be great to allow changing it from the callback. It could be done via a new 2nd argument, passed by reference to the callback.
  2. as stated in the doc, apcu_entry() locks concurrent read-access. But this behavior breaks stampede protection, as this lock prevents concurrent access from serving any "stale" value. An idea to improve this behavior could be to add a 3rd argument to the function, called $beta, defaulting to zero for BC. When provided, $beta would trigger probabilistic early expiration (providing INF would force immediate expiration).

nicolas-grekas avatar Apr 18 '18 09:04 nicolas-grekas