redis-patterns

Implement Redis caching, distributed locking, and rate limiting in Laravel applications.

Updated Jan 6, 2023
One-click install
npx skills add https://github.com/pekral/phpstan-rules --skill redis-patterns-pekral
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: redis-patterns
Source: https://github.com/pekral/phpstan-rules/tree/main/.claude/skills/redis-patterns
Command: npx skills add https://github.com/pekral/phpstan-rules --skill redis-patterns-pekral

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill addresses the complexity of implementing robust Redis-based caching, distributed locking, and rate limiting in Laravel applications, preventing common pitfalls like thundering herds, memory exhaustion, and race conditions.

Core Features & Use Cases

  • Caching Strategies: Implements cache-aside, write-through, and tag-based invalidation patterns to optimize read-heavy data.
  • Concurrency Control: Provides patterns for distributed locks and atomic rate limiting to ensure data integrity across multiple workers.
  • Operational Safety: Enforces TTL discipline, eviction policy alignment, and stampede protection to maintain system stability.

Quick Start

Use the redis-patterns skill to implement a stampede-protected cache-aside pattern for a high-traffic database query.

Frequently Asked Questions about redis-patterns

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

FAQPage Schema
How do I prevent cache stampedes in Laravel when using Redis for high-traffic database queries?

To prevent cache stampedes in Laravel Redis, implement stampede-protected cache-aside patterns that enforce atomic operations and strict TTL management, ensuring concurrent requests wait for a single cache rebuild instead of overwhelming the database.

What is the best way to implement distributed locking in Laravel to manage concurrency across multiple workers?

Distributed locking in Laravel manages concurrency by utilizing Redis atomic operations to acquire and release locks across multiple workers, ensuring data integrity and preventing race conditions in high-scale PHP environments.

How do I configure Redis rate limiting in Laravel for distributed systems?

Redis rate limiting in Laravel distributed systems is configured using atomic operation principles, allowing you to enforce concurrency control and strict limits across multiple workers without risking data integrity or race conditions.

When should I use tag-based cache invalidation over write-through caching in Laravel Redis?

Tag-based cache invalidation is ideal for read-heavy data requiring targeted eviction, whereas write-through caching ensures data consistency by writing to the cache and database simultaneously, preventing memory exhaustion and maintaining system stability.

What TTL discipline and eviction policies are needed for memory-efficient Redis key design in Laravel?

Memory-efficient Redis key design in Laravel requires strict TTL discipline for all cached data and alignment with Redis eviction policies, preventing memory exhaustion and maintaining operational safety under high-scale workloads.

Do I need Laravel facade usage to implement atomic Redis caching patterns?

Yes, implementing atomic Redis caching patterns in Laravel requires adherence to Laravel facade usage, which provides the necessary interface for atomic operations, distributed locking, and strict TTL management across your application.