memoizeCallable.php
Table of Contents
Functions
- memoizeCallable() : callable
- Memoizes a callable's result (caches based on arguments).
Functions
memoizeCallable()
Memoizes a callable's result (caches based on arguments).
memoizeCallable(callable $callable) : callable
Returns a new callable that caches results based on the arguments passed. Subsequent calls with the same arguments return the cached result instead of re-executing the original callable. This improves performance for expensive computations with repeated identical arguments.
Cache keys are generated by serializing arguments using serialize().
Works with scalar values, arrays, and objects that support serialization.
WARNING: The cache grows indefinitely. For long-running processes with many unique argument combinations, consider clearing the cache or using a size limit.
Parameters
- $callable : callable
-
The original callable to memoize
Tags
Return values
callable —A new callable with memoization enabled