spatie/once
A magic memoization function observed · 2026-08-28
Health v2 · maintenance only
70/100
- Activity 91
- Release rhythm 26
- Longevity 100
How is this computed?
round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10) — computed 2026-09-03. Adoption (stars, forks) is never an input.
- gap_med: n/a
- age_days: 3587
- days_rel: 281
- days_push: 55
- n_releases_24m: 1
Adoption not part of the score
1446 stars · 62 forks observed · 2026-08-28
What it is AI-extracted, prompt v1, taxonomy v1, 2026-08-30, confidence not recorded
A small PHP package providing a magic `once()` memoization function that caches a callable's result per object instance and argument combination using PHP 8 WeakMaps. It ensures expensive computations run only once per request lifecycle.
Use cases
- memoize expensive method calls in php
- cache a function result per object instance
- avoid recomputing values within the same request
- memoize static methods with argument-specific results
- run a callable only once per argument combination
When to choose
- you need lightweight per-object memoization in PHP 8+
- you want results cached only for the current request without a global cache
- you need argument-aware memoization including static contexts
When to avoid
- you need persistent or cross-request caching (use Redis, APCu, or Laravel cache)
- you target PHP versions older than 8.0
- you need cache invalidation or TTL semantics
Facets
library · maturity stable
caching developer-tools performance php memoization weakmap per-request-cache
4 sources
- readme: https://github.com/spatie/once · fetched 2026-08-28 · edb18e7db8cb
- homepage: https://spatie.be/opensource · fetched 2026-08-29 · 4a0ae7f7c9b6
- site_page: https://spatie.be/docs · fetched 2026-08-29 · 08e024d86d95
- site_page: https://spatie.be/about-us · fetched 2026-08-29 · d3cb88e4b34c
Member repositories
| Repository | Role | Health v2 |
|---|---|---|
| spatie/once | main | 70 |
For agents
Data as of 2026-08-30T08:39:29.467469+00:00 · Report a problem