Memoize Method Calls in PHP with Cache Decorators

Beitrag ist nur auf Englisch erschienen

4 Replies to “Memoize Method Calls in PHP with Cache Decorators”

  1. This is CACHE, not memoize. Memoize is for constants, general cache is for variables.
    You cannot memoize anything like $id -> $object _from_external_source (that can be modified or not available.
    The requirement to memoize is that it only works with pure functions(immutable input, immutable output), not with procedures/methods or anything that touches the network or external memory (globals, $this, closures).
    It must be deterministic, you cannot memoize random_bytes or random_int for example. But you can memoize cos, sin, …, you can use memoize for fourier transform (worthy, lengthy but pure).
    In other words, if you cannot map a set A to a set B, it is not memoizable.

Comments are closed.