Beitrag ist nur auf Englisch erschienen
4 Replies to “Memoize Method Calls in PHP with Cache Decorators”
Comments are closed.
Dipl. Inform. Fabian Schmengler | Magento Certified Developer | Magento Certified Solution Specialist
Beitrag ist nur auf Englisch erschienen
Comments are closed.
Manchmal möchte man eine Klasse umbenennen oder sie in einen anderen Namespace verschieben. Aber sobald sie irgendwo außerhalb des Packages...
Thanks for sharing! Just to let you know that it’s already implemented in Hack language: https://docs.hhvm.com/hack/attributes/special#__memoize
Nice! I didn’t know that, but have to admit that I never actually tried out Hacklang
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.
Thanks for the clarification!