0021-laravel-caching-strategies

Design Laravel cache strategies using tags, locks, and key conventions.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/MrJmpl3/codex_____data_____configuration --skill 0021-laravel-caching-strategies
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: 0021-laravel-caching-strategies
Source: https://github.com/MrJmpl3/codex_____data_____configuration/tree/main/skills/0021-laravel-caching-strategies
Command: npx skills add https://github.com/MrJmpl3/codex_____data_____configuration --skill 0021-laravel-caching-strategies

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It prevents slow database-heavy requests by showing how to cache Laravel results correctly while avoiding stale data, stampedes, and broken invalidation.

Core Features & Use Cases

  • Cache patterns and lifecycles: Use remember, rememberForever, put/get/forget, and flexible stale-while-revalidate for high-traffic keys.
  • Grouped invalidation: Apply cache tags for Redis/Memcached so you can flush related entries together.
  • Concurrency control: Use atomic locks and memoization patterns to stop duplicate regeneration and redundant cache lookups.
  • Practical correctness: Establish cache key conventions and handle null/empty caching with explicit strategies.
  • Real invalidation workflows: Invalidate cached model entries on save/delete and invalidate query-result caches by tag.

Quick Start

Ask an AI to produce a Laravel caching plan for a dashboard that needs fast reads, safe refresh behavior, and correct invalidation when posts or user profiles change.

Frequently Asked Questions about 0021-laravel-caching-strategies

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent cache stampedes when regenerating expensive Laravel queries?

Prevent Laravel cache stampedes by applying atomic locks to enforce exclusive execution during cache regeneration, stopping duplicate processes from overwhelming your database when high-traffic keys expire simultaneously.

What is the best way to invalidate grouped Laravel cache entries on model save or delete?

Invalidate grouped Laravel cache entries by applying Redis or Memcached cache tags, allowing you to flush related query-result caches together automatically when underlying model data changes on save or delete.

How does stale-while-revalidate work for high-traffic Laravel cache keys?

Stale-while-revalidate works in Laravel by serving stale cached data immediately while triggering a background regeneration process, ensuring users get fast responses without waiting for expensive database queries to finish.

Can I use cache tags to flush related query results in Laravel?

Yes, you can use cache tags in Laravel with Redis or Memcached to group related cache entries, enabling you to flush specific query-result caches together without clearing the entire cache store.

When should I use atomic locks for Laravel caching?

Use atomic locks for Laravel caching when regenerating expensive database queries to prevent cache stampedes, ensuring only one process executes the regeneration while others wait or serve stale data.

Does Laravel flexible caching support null and empty value strategies?

Yes, Laravel caching strategies handle null and empty values by establishing explicit cache key conventions, ensuring consistent behavior when caching query results that return empty datasets or null values.