Registry / utility / spatie-once

spatie-once

JSON →
library3.1.2phppackagistunverified

A magic memoization function

composer require spatie/once
INSTALL
IMPORT
SIG · SPATIE-ONCE
S
spatie-once
utilityphpv3.1.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Cache
✓ use Spatie\Once\Cache;

Memoize a function call

use Spatie\Once\Cache; $result = once(function () { return expensiveComputation(); });
Debug
Known issues
gotchaThe once() function may not work as expected with closures that capture variables by reference
fix
Use use statements to pass variables explicitly
affects: *
Upgrade
Version history
3.1.2latest on Packagist
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
Resources
spatie-once — pip install spatie-once · libregistry