redis
Skill4 starsChanged 4 months agoMITView on GitHub
Use Redis from PHP as a cache, session store, queue backend, and rate-limiter store — pick phpredis or predis, model data with the right structures, and tune persistence (RDB/AOF), eviction, and clustering for production. Use when the user wants to cache expensive query results, computed values, or fragments in memory to reduce database load and speed up responses; the user needs to choose or configure a Redis client for PHP — phpredis (the C extension) versus predis (pure PHP) — or connect PHP to a Redis server or cluster; the user wants to store sessions, rate-limiter counters, locks, or a queue backend in Redis, and needs the right data structure, expiry, and persistence. Keywords: redis, cache, caching, performance, sessions, rate-limiting, phpredis, predis, persistence, eviction, clustering, queue.
11 other projects use a version of this.
Adopted by
Most recently taken up by
- G1Joshi/Agent-Skillstheir own version, first seen Oct 13, 2026
- Alteriom/ai-dev-skillstheir own version, first seen Oct 11, 2026
- kid-sid/claude-spellbooktheir own version, first seen Oct 9, 2026
- derogab/agent-kittheir own version, first seen Oct 5, 2026
- fworks-tech/agenthoodtheir own version, first seen Sep 28, 2026
- muxammadmamajonov/dot-claudetheir own version, first seen Jul 6, 2026
Used with
Projects with it also use mysql, postgres and 5 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
planetscaleSkillmysql
Plan and review MySQL/InnoDB schema, indexing, query tuning, transactions, and operations. Use when creating or modifying MySQL tables, indexes, or queries; diagnosing slow/locking behavior; planning migrations; or troubleshooting replication and connection issues. Load when using a MySQL database.
Also in 3 projects that use this
digitalocean-labsSkillpostgres
Configure DigitalOcean Managed Postgres with bindable variables or schema isolation. Use when setting up databases, creating users, managing permissions, configuring multi-tenant schemas, or troubleshooting database connectivity on App Platform.
Also in 3 projects that use this
VercelSkillaws
Emulated AWS cloud services (S3, SQS, Cognito, IAM, STS) for local development and testing. Use when the user needs to interact with AWS API endpoints locally, test S3 bucket and object operations, emulate SQS queues and messages, test Cognito sign-up, sign-in, JWTs, or Identity Pools, manage IAM users/roles/access keys, test STS assume role, or work without hitting real AWS APIs. Triggers include "AWS emulator", "emulate AWS", "mock S3", "local SQS", "test IAM", "emulate S3", "AWS locally", "STS assume role", or any task requiring local AWS service emulation.
Also in 3 projects that use this
VercelSkillreact
React renderer for json-render that turns JSON specs into React components. Use when working with @json-render/react, building React UIs from JSON, creating component catalogs, or rendering AI-generated specs.
Also in 3 projects that use this
OpenAISkillobservability
Vercel Observability expert guidance — Drains (logs, traces, speed insights, web analytics), Web Analytics, Speed Insights, runtime logs, custom events, OpenTelemetry integration, and monitoring dashboards. Use when instrumenting, debugging, or optimizing application performance and user experience on Vercel.
Also in 3 projects that use this
MicrosoftSkillapi-design
Guide for designing and documenting RESTful APIs. Use when asked to design an API, create endpoints, or document an API.
Also in 3 projects that use this
Other versions11 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 11
- kid-sid/claude-spellbook★ 190same name
- G1Joshi/Agent-Skills★ 15same name
- derogab/agent-kit★ 4same name
- fworks-tech/agenthood★ 3same name
- dversoza/claude-skills★ 2same name
- ffsshhttiikk/opencode-agents-skills★ 2same name
- Sorcha-Platform/Sorcha★ 2same name
- Alteriom/ai-dev-skills★ 0same name
- muxammadmamajonov/dot-claude★ 0same name
- sudarshanpjadhav/finggu-skills★ 0same name
1 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository119 other files it gives its agents.
- strategy-bitrix-d7-incrementalSkill
- strategy-explicit-over-magicSkill
- strategy-framework-conventionsSkill
- strategy-legacy-safe-editsSkill
- strategy-minimal-diffSkill
- strategy-no-untested-refactorSkill
- strategy-preserve-public-apiSkill
- strategy-readonly-immutabilitySkill
- strategy-security-firstSkill
- strategy-test-drivenSkill
- openapiSkill
- paginationSkill
- rest-designSkill
- versioningSkill
- cqrsSkill
- dependency-inversionSkill
- hexagonalSkill
- repository-patternSkill
- service-layerSkill
- bitrixSkill
- findings-reportSkill
- laravelSkill
- performanceSkill
- phpSkill
- project-analysisSkill
- refactoringSkill
- roi-prioritizationSkill
- securitySkill
- stack-detectionSkill
- cache-layersSkill
- component-engineSkill
- d7-eventsSkill
- d7-loaderSkill
- d7-orm-queriesSkill
- iblock-elementsSkill
- kernel-main-moduleSkill
- localizationSkill
- controllersSkill
- ormSkill
- validationSkill
- controllersSkill
- query-builderSkill
- routingSkill
- autoload-psr4Skill
- dependency-managementSkill
- scriptsSkill
- connection-poolingSkill
- mysql-indexingSkill
- transactionsSkill
- ci-github-actionsSkill
- deployment-strategiesSkill
- docker-phpSkill
- env-configSkill
- associationsSkill
- entities-mappingSkill
- orm-basicsSkill
- entity-apiSkill
- module-developmentSkill
- routing-controllersSkill
- formsSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
13 rules. 0 are common, 7 are distinctive, and 6 are very specific to this project.
0
Common
Most of the 10 edited versions we read keep these.
7
Distinctive
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 80
Do not use Redis as the primary durable store for records you cannot afford to lose.
- Distinctive: line 82
Do not reach for Redis when the workload needs ad-hoc queries, joins, secondary indexes, or transactions across many rows.
- Distinctive: line 132
Verify: A warm key returns from Redis and the database query is skipped.
- Distinctive: line 135
Verify: Concurrent misses trigger one database load and the value is stored with a TTL.
- Very specific: line 136
When the underlying record changes, DEL the cache key (or bump the key version) inside the same write path so the next read repopulates …
- Distinctive: line 138
Verify: Updating the record makes the next read miss the cache and reload from the database.
- Very specific: line 154
Verify: $redis->ping() returns true and the connection is persistent across requests.
- Very specific: line 157
Verify: CONFIG GET maxmemory and maxmemory-policy return the intended values.
- Very specific: line 158
Run a smoke test that writes and reads a TTL key, then check INFO for used_memory, evicted_keys, and connected_clients to confirm healthy …
- Distinctive: line 160
Verify: The smoke key round-trips, expires on schedule, and INFO shows stable memory and client counts.
- Very specific: line 167
Use RDB snapshots when a cache can tolerate losing the last few minutes on crash.
- Very specific: line 172
When issuing many commands, batch them with a pipeline (multi(Redis::PIPELINE)) or multi-key ops like MGET/MSET instead of one blocking …
- Distinctive: line 233
Not applicable — no I/O, auth, or untrusted input.
“Common” is measured: kept by at least 6 in 10 of the 10 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
<!-- generated: do not edit — source: knowledge/atoms/databases/redis/ --><!-- schema: atomVersion=3 skillVersion=2 graphVersion=1 --><!-- compile: @php-skills/compiler v1.0.0 (deterministic build) -->Redis for PHP
When to use
- The user wants to cache expensive query results, computed values, or fragments in memory to reduce database load and speed up responses.
- The user needs to choose or configure a Redis client for PHP — phpredis (the C extension) versus predis (pure PHP) — or connect PHP to a Redis server or cluster.
- The user wants to store sessions, rate-limiter counters, locks, or a queue backend in Redis, and needs the right data structure, expiry, and persistence.
When NOT to use
- Do not use Redis as the primary durable store for records you cannot afford to lose; keep the source of truth in a relational or document database.
- Do not reach for Redis when the workload needs ad-hoc queries, joins, secondary indexes, or transactions across many rows; use a relational database instead.
Core guidance
- Prefer phpredis in production, predis when you cannot install extensions — Use the phpredis C extension for production throughput; fall back to predis (pure PHP) only when you cannot install PHP extensions, such as some managed hosts.
- Set a TTL on every cache key — Give every cache entry an explicit TTL (
SET key val EX 3600orSETEX) so stale data expires and memory is reclaimed automatically.
Decision Engine
Walk this section before choosing an implementation path.
Can you install PHP C extensions on the host, and do you need horizontal scale
or high availability beyond a single Redis node?
├── Dataset or write load exceeds one node: → Redis Cluster — data sharded across nodes with hash slots; use hash tags to keep
related keys co-located and accept that multi-key ops must stay in one slot.
├── Can install extensions, single node is enough: → phpredis (C extension) against a single primary — the fastest, lowest-memory
client and the default choice for throughput on one node.
├── Cannot install extensions: → predis (pure PHP) — no extension to compile, easy to deploy on locked-down
managed hosts; accept lower throughput than phpredis.
└── Need failover but data fits one master: → Redis Sentinel with a primary/replica set — automatic failover and read
replicas while the dataset still fits one master's memory.
Full engine: references/decision-engine.md — Decision Tree, Priority Matrix, Decision Table.
Workflows
Workflow: Cache Aside
Progress:
- [ ] Compose a namespaced, versioned key (`user:v1:42:profile`) and `GET` it; on a hit,
decode and return the cached value without touching the database
- [ ] On a miss, take a short `SET lock NX EX` so only one worker recomputes, load from
the database, then `SET key value EX <ttl>` (add jitter) and release the lock
- [ ] When the underlying record changes, `DEL` the cache key (or bump the key version)
inside the same write path so the next read repopulates fresh data- Compose a namespaced, versioned key (
user:v1:42:profile) andGETit; on a hit, decode and return the cached value without touching the database.- Verify: A warm key returns from Redis and the database query is skipped.
- On a miss, take a short
SET lock NX EXso only one worker recomputes, load from the database, thenSET key value EX <ttl>(add jitter) and release the lock.- Verify: Concurrent misses trigger one database load and the value is stored with a TTL.
- When the underlying record changes,
DELthe cache key (or bump the key version) inside the same write path so the next read repopulates fresh data.- Verify: Updating the record makes the next read miss the cache and reload from the database.
Workflow: Configure Client
Progress:
- [ ] Install the phpredis extension (`pecl install redis`), then in code `pconnect()`
to the host and `AUTH` if required, setting connect and read timeouts
- [ ] In redis.conf set `maxmemory` to a safe ceiling, choose `maxmemory-policy`
(allkeys-lru for cache), and set persistence (RDB save points and/or `appendonly yes`)
- [ ] Run a smoke test that writes and reads a TTL key, then check `INFO` for
used_memory, evicted_keys, and connected_clients to confirm healthy operation- Install the phpredis extension (
pecl install redis), then in codepconnect()to the host andAUTHif required, setting connect and read timeouts.- Verify:
$redis->ping()returns true and the connection is persistent across requests.
- Verify:
- In redis.conf set
maxmemoryto a safe ceiling, choosemaxmemory-policy(allkeys-lru for cache), and set persistence (RDB save points and/orappendonly yes).- Verify:
CONFIG GET maxmemoryandmaxmemory-policyreturn the intended values.
- Verify:
- Run a smoke test that writes and reads a TTL key, then check
INFOfor used_memory, evicted_keys, and connected_clients to confirm healthy operation.- Verify: The smoke key round-trips, expires on schedule, and INFO shows stable memory and client counts.
Best practices
- For a pure cache, set
maxmemoryandmaxmemory-policy allkeys-lru(orallkeys-lfu); for a store mixing cache and durable keys, usevolatile-lruso only keys with a TTL are eligible for eviction - Use RDB snapshots when a cache can tolerate losing the last few minutes on
crash; enable AOF (
appendonly yes,appendfsync everysec) when you need near write-durability; run both for fast restarts plus a durable log - Under PHP-FPM, open persistent connections with
pconnect()(or a pool in long-running workers) so each request reuses a socket instead of a fresh handshake - When issuing many commands, batch them with a pipeline (
multi(Redis::PIPELINE)) or multi-key ops likeMGET/MSETinstead of one blocking call per key
Anti-patterns
| Anti-pattern | Why it fails | Do instead |
| Storing giant blobs or one huge collection in a single key | Big keys make every op on them slow and block the server, replication ships the<br>whole value, and eviction of one key can drop a large slice of state at once. | Split large data into smaller keys or Hash fields, cap collection sizes, and keep<br>values small; store large binaries in object storage and cache only a pointer. |
| Opening a new connection per operation | A fresh TCP connect plus AUTH per call adds latency and exhausts the server's<br>client limit under load, causing intermittent connection errors. | Reuse a persistent connection with pconnect() under PHP-FPM, or a shared client<br>or pool in long-running workers, with sane connect and read timeouts. |
| Using Redis as the primary system of record | Redis is memory-first and can drop recent writes on crash depending on<br>persistence config; treating it as the source of truth risks silent data loss. | Keep the durable record in a relational or document database and use Redis as a<br>cache or ephemeral store, rebuildable from the source of truth. |
See references/anti-patterns.md.
Debugging
- Using KEYS in production blocks the server — Redis processes commands one at a time, so a full scan stalls all concurrent requests. Fix: Iterate with
SCAN/HSCAN/SSCANusing a cursor and small COUNT, or maintain a purpose-built index Set instead of scanning at runtime. - Cache keys without TTL leak memory — Redis never removes a key on its own without a TTL or an eviction policy that targets it. Fix: Always
SET ... EX <seconds>(orSETEX) for cache data, and configure an eviction policy so keyless growth cannot OOM the instance. - Non-atomic check-then-set races between requests — The gap between read and write lets a concurrent client change the value, corrupting locks and counters. Fix: Use atomic primitives —
INCR/INCRBYfor counters,SET key val NX EXfor locks, or a Lua script viaEVALfor multi-step logic that must be atomic. - Mismatched serialization corrupts cached values — Redis stores opaque bytes, so writer and reader must agree on the encoding. Fix: Pick one serialization strategy per key namespace, set the phpredis serializer consistently, and version or prefix keys when you change the format.
Performance notes
- Using KEYS in production blocks the server — Calling
KEYS pattern*(orSMEMBERSon a huge set) scans the whole keyspace in one blocking pass, freezing the single-threaded server for every other client. - Cache keys without TTL leak memory — Writing cache entries with no expiry lets the keyspace grow without bound until Redis hits maxmemory and either evicts unpredictably or rejects writes.
- Match the maxmemory-policy to the workload — For a pure cache, set
maxmemoryandmaxmemory-policy allkeys-lru(orallkeys-lfu); for a store mixing cache and durable keys, usevolatile-lruso only keys with a TTL are eligible for eviction. - Reuse connections with pconnect or a pool — Under PHP-FPM, open persistent connections with
pconnect()(or a pool in long-running workers) so each request reuses a socket instead of a fresh handshake. - Prefer phpredis in production, predis when you cannot install extensions — Use the phpredis C extension for production throughput; fall back to predis (pure PHP) only when you cannot install PHP extensions, such as some managed hosts.
- Pipeline or MGET batches instead of chatty round-trips — When issuing many commands, batch them with a pipeline (
multi(Redis::PIPELINE)) or multi-key ops likeMGET/MSETinstead of one blocking call per key. - Set a TTL on every cache key — Give every cache entry an explicit TTL (
SET key val EX 3600orSETEX) so stale data expires and memory is reclaimed automatically.
Production checklist
- Counters use INCR, locks use SET NX EX, and multi-step logic uses a Lua script rather than a read-modify-write race.
- maxmemory is capped and an eviction policy (allkeys-lru or volatile-lru) is chosen, never the default noeviction for a cache.
- Hot paths use SCAN or an index Set instead of KEYS, and no single key holds an unbounded blob or collection.
- RDB and/or AOF are configured to match how much recent data the workload can afford to lose on restart.
- The app uses pconnect or a pool with sane timeouts so it does not open a fresh socket per operation.
- Every cache entry is written with an explicit TTL so stale data expires and memory is reclaimed.
Version notes
- LFU eviction and phpredis serializers (PHP >=7.4) —
allkeys-lfu/volatile-lfueviction policies are available from Redis 4.0, and the phpredis igbinary serializer requires the igbinary extension; older Redis supports only LRU/random/ttl policies. - phpredis and predis both support PHP 7.4+ (PHP >=7.4) — phpredis 5.x and predis 1.1/2.x both run on PHP 7.4 and up; predis 2.x drops PHP 7.2 support, so pin predis 1.1 only if you must stay on very old PHP.
Security
- Not applicable — no I/O, auth, or untrusted input.
Testing
- Activation and decision behavior are verified in
eval/scenarios/databases/redis.yaml.
Additional resources
- references/anti-patterns.md
- references/core.md
- references/decision-engine.md
- references/examples.md
- references/pitfalls.md
- references/recipes.md
- references/version-differences.md
Knowledge graph
Related: audit/performance, audit/project-analysis, laravel/queues, security/rate-limiting
<!-- graph-fragment: graph/fragments/databases/redis.yaml -->Skill contract
Produces: cache.redis-configured, infra.redis-connected
Risk: medium · Confidence: 0.9
<!-- contract-fragment: contracts/fragments/databases/redis.yaml -->Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

