proomt

Search

Search posts, papers, and topics

All posts

LaravelPaul Redmond2 min readintermediate

Memoize Tagged Cache Reads in Laravel

Summary

Laravel 13.33 adds tag support to its memoized cache, letting you cache‑once per request and serve subsequent reads from memory. Use it for request‑scoped immutable data like permissions to avoid repeated store hits, but remember writes invalidate the memoized copy.

  • Call `Cache::memo()->tags([...])` to memoize a tagged cache entry for the duration of a request or job.
  • After the first read the value is served from memory; any write (put, increment, etc.) clears the memoized copy so the next read hits the store.
  • Ideal for data that doesn’t change during a request, such as permission sets or configuration settings.
  • Avoid for counters or data that other processes may update mid‑request, as memoization can hide those changes.

Laravel engineers building high‑traffic applications can reduce redundant cache reads and improve request latency by memoizing tagged values that stay constant during a request.

6/10

Related reading

  1. What We Know About Laravel 14

    Laravel 14 (Q1 2027) raises the PHP minimum to 8.4 and adds several concrete API changes: a new `Route::query()` method, `$user->authorize()`, context support for `report()`, `Storage::fake()` for on‑demand disks, extended `whereKey*()` helpers, and fixes to queue‑pause signatures, non‑mutating `lazy()`/`chunk()`, array handling in `Cache::has/forget`, and `MassPrunable` soft‑delete behavior. The…

    Laravellaravel-news.com5 min
  2. Laravel Scalpel Scans for Filesystem Intrusion Evidence

    Laravel Scalpel is a Laravel‑native scanner that looks for post‑deployment filesystem tampering – rogue PHP files, obfuscated backdoors, altered .htaccess/.user.ini, missing or mis‑configured .env, and diffs against a signed baseline. It ships with six built‑in scanners, baseline snapshot commands, fast vs strict hashing modes, CI‑friendly output (JSON, SARIF, GitHub annotations) and a ScanFinish…

    Laravellaravel-news.com5 min
  3. Measuring the back/forward cache with Application Metrics

    The back/forward cache (bfcache) provides instant page navigation, but traditional performance tools cannot measure its effectiveness, creating a blind spot. Sentry's new `bfcacheMetricsIntegration` addresses this by exposing bfcache hits, misses, and reasons as application metrics, allowing engineers to track and optimize this critical user experience.

    Sentrysentry.io5 min
  4. A practical guide to cost optimization with Lakebase Postgres

    Lakebase’s separated storage‑compute architecture lets you cut database costs by syncing only the active data, picking the right sync mode, and right‑sizing compute so the hot working set fits in cache. Follow the blog’s concrete steps—materialized‑view subsets, snapshot vs triggered vs continuous sync, autoscale bounds, and connection‑pooling—to keep spend predictable without sacrificing perform…

    Databricksdatabricks.com12 min