On Sun, Jul 19, 2026, at 12:06 AM, Go Kudo wrote:
> Hi internals,
>
> This is a follow-up to the previous "OPcache Static Cache" discussion.
>
> I have written a new RFC and implementation. It addresses the issues
> raised in the previous thread, drops the parts that led to feature
> creep, and moves from OPcache integration to a new bundled
> `user_cache` extension. 
>
> (The `OPcache User Cache` entry in the commit history is a remnant of
> a completely new implementation built from scratch. 
> After realizing partway through that it wasn't necessary to depend on
> OPcache, I separated it.)
>
> RFC: https://wiki.php.net/rfc/impl_user_cache
> Implementation: https://github.com/php/php-src/pull/22730
>
> The scope and API have changed a lot from the previous proposal, so I
> am starting this as a new RFC with its own discussion period. Because
> of that, I am not sure it can make the PHP 8.6 feature freeze. If the
> release managers think 8.6 is not realistic, I will target 8.7.
>
> As mentioned in the previous thread, I think library developers would
> benefit from having this available sooner, so feedback is welcome.
>
> Best regards
> Go Kudo

Hi Go.  First off, I think it's unrealistic for this to make into 8.6 at this 
point.  Especially as it is technically a new RFC now.  8.7 is fine, though.  
(Or 9, if that's what we call it.)

Which means it's worth considering if the TTL and Lease should use the Duration 
class rather than ints, as it seems likely to pass.

As to the proposal itself, I overall like it.  The remember() method is 
especially useful, and what I suspect most people (or at least me) will use in 
practice, especially now that we have FCC.

class ExpensiveThing {
  public array $lookup { get => $this->lookup ??= 
Cache::getPool('expensive')->remember($this->compute(...), 10); }

  private function compute() {
    // Lots of expensive stuff here.
  }
}

That said, remember() doesn't seem to have any lock interaction, which I could 
see being a problem for exactly that sort of scenario.  I'm not entirely 
certain what the interaction should be, but it should be thought through.

I'm not sure why store() and add() are both necessary.  What are the practical 
uses cases for using add() instead of store()?

It's worth noting explicitly that the cache layering is transparent and largely 
invisible to the user.

Question: Is it possible to cache a closure?  What layer would that live in?

The Locking Semantics section looks to have numerous typos and grammatical 
errors, making it hard to follow.  Please clean it up.  (The rest of the doc 
seems fine.)

--Larry Garfield

Reply via email to