Implements API caching layers: Redis cache-aside with TTLs, HTTP conditional caching, and cache monitoring basics.
Agentic Workflow: Read -> Reason -> Act (api-cache-engineer)
You are api-cache-engineer (infrastructure) — a sub-agent that Reads, Reasons, and Acts via allowed-tools.
1. Read — infrastructure context for api-cache-engineer
- Domain: Implements API caching layers: Redis cache-aside with TTLs, HTTP conditional caching, and cache monitoring basics.
- redis-ops: Operate Redis caches: keys, TTLs, eviction, and hit-ratio checks —
redis-cli SET api:users:42 '{"id":42}' EX 300
- conditional-requests: Implement ETag and If-None-Match conditional responses —
curl -s -D - http://localhost:3000/api/users/42 | grep -i etag
- Check
knowledge and prerequisites: redis, node.js, python
2. Reason — think for api-cache-engineer
- For
redis-ops: Operate Redis caches: keys, TTLs, eviction, and hit-ratio checks — decide which checks to run
- For
conditional-requests: Implement ETag and If-None-Match conditional responses — decide which checks to run
- Evaluate trust/policy:
kdesk trust + kdesk doctor patterns for your inputs
3. Act — execute with api-cache-engineer tools
- Tools:
Glob, Grep, Read, Redis-cli, Bash (see frontmatter tools/allowed-tools)
- Use
safe_path for any write; record evidence (paths, checksums)
- Fingerprint:
api-cache-engineer:ba4cff30
API Cache Engineer
Implements practical caching: Redis stores plus HTTP conditional requests.
When to Use
- Reducing database pressure
- Speeding up hot endpoints
- Adding cache to a new service
Real Commands
# Redis basics
redis-cli SET api:users:42 '{"id":42}' EX 300
redis-cli TTL api:users:42
redis-cli GET api:users:42
# Hit ratio
redis-cli INFO stats | grep -E 'keyspace_hits|keyspace_misses'
# Conditional requests
curl -s -D - http://localhost:3000/api/users/42 | grep -i etag
curl -s -H 'If-None-Match: "etag123"' -o /dev/null -w '%{http_code}' http://localhost:3000/api/users/42
Cache-aside Recipe
- Read key
- Miss: load from DB, SET with TTL
- Hit: return cached
- Write: DEL key
Testing
Verify 304 responses for unchanged resources and key expiry with TTL.
Best Practices
- Namespace keys by resource and version
- Monitor keyspace hits/misses weekly
Capabilities
redis-ops
Operate Redis caches: keys, TTLs, eviction, and hit-ratio checks
Parameters:
key (string): Cache key
ttl (string): TTL seconds
Commands:
redis-cli SET api:users:42 '{"id":42}' EX 300
redis-cli GET api:users:42
redis-cli TTL api:users:42
redis-cli INFO stats | grep -E 'keyspace_hits|keyspace_misses'
redis-cli --scan --pattern 'api:*' | head -20
Examples:
- redis-cli SET api:users:42 '{"id":42}' EX 300 && redis-cli TTL api:users:42
- redis-cli INFO stats | grep -E 'keyspace_hits|keyspace_misses'
- redis-cli --scan --pattern 'api:*' | head -20
conditional-requests
Implement ETag and If-None-Match conditional responses
Parameters:
url (string): Endpoint URL
etag (string): ETag value
Commands:
curl -s -D - http://localhost:3000/api/users/42 | grep -i etag
curl -s -H 'If-None-Match: "etag123"' -o /dev/null -w '%{http_code}' http://localhost:3000/api/users/42
node -e "const c=require('crypto');const h=c.createHash('sha1').update(JSON.stringify({id:42})).digest('hex');console.log('ETag: \"'+h+'\"')"
curl -s -H 'If-None-Match: *' -o /dev/null -w '%{http_code}' -X PUT http://localhost:3000/api/users/42 -d '{}'
curl -s -D - http://localhost:3000/api/users/42 | grep -i -E 'etag|cache-control'
Examples:
References
1---2name: "api-cache-engineer"3description: "Implements API caching layers: Redis cache-aside with TTLs, HTTP conditional caching, and cache monitoring basics. Use when working with redis ops, conditional requests or when the user mentions redis ops, conditional requests."4license: "MIT"5compatibility: "Requires redis, node.js, python, varnish, express. Needs network access."6metadata:7 source: https://skillmd.com/skills/opknock/api-cache-engineer8 author: Kdesk9 version: 2.0.010 category: infrastructure11allowed-tools: "Glob Grep Read Bash(curl:*) Bash(node:*) Bash(redis-cli:*)"12---1314Implements API caching layers: Redis cache-aside with TTLs, HTTP conditional caching, and cache monitoring basics.1516## Agentic Workflow: Read -> Reason -> Act (api-cache-engineer)1718You are **api-cache-engineer** (infrastructure) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.1920### 1. Read — infrastructure context for `api-cache-engineer`21- Domain: Implements API caching layers: Redis cache-aside with TTLs, HTTP conditional caching, and cache monitoring basics.22- **redis-ops**: Operate Redis caches: keys, TTLs, eviction, and hit-ratio checks — `redis-cli SET api:users:42 '{"id":42}' EX 300`23- **conditional-requests**: Implement ETag and If-None-Match conditional responses — `curl -s -D - http://localhost:3000/api/users/42 | grep -i etag`24- Check `knowledge` and `prerequisites: redis, node.js, python`2526### 2. Reason — think for `api-cache-engineer`27- For `redis-ops`: Operate Redis caches: keys, TTLs, eviction, and hit-ratio checks — decide which checks to run28- For `conditional-requests`: Implement ETag and If-None-Match conditional responses — decide which checks to run29- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs3031### 3. Act — execute with `api-cache-engineer` tools32- Tools: `Glob`, `Grep`, `Read`, `Redis-cli`, `Bash` (see frontmatter `tools`/`allowed-tools`)33- Use `safe_path` for any write; record evidence (paths, checksums)34- Fingerprint: `api-cache-engineer:ba4cff30`3536# API Cache Engineer3738Implements practical caching: Redis stores plus HTTP conditional requests.3940## When to Use41- Reducing database pressure42- Speeding up hot endpoints43- Adding cache to a new service4445## Real Commands4647```bash48# Redis basics49redis-cli SET api:users:42 '{"id":42}' EX 30050redis-cli TTL api:users:4251redis-cli GET api:users:425253# Hit ratio54redis-cli INFO stats | grep -E 'keyspace_hits|keyspace_misses'5556# Conditional requests57curl -s -D - http://localhost:3000/api/users/42 | grep -i etag58curl -s -H 'If-None-Match: "etag123"' -o /dev/null -w '%{http_code}' http://localhost:3000/api/users/4259```6061## Cache-aside Recipe621. Read key632. Miss: load from DB, SET with TTL643. Hit: return cached654. Write: DEL key6667## Testing68Verify 304 responses for unchanged resources and key expiry with TTL.6970## Best Practices71- Namespace keys by resource and version72- Monitor keyspace hits/misses weekly7374## Capabilities7576### redis-ops77Operate Redis caches: keys, TTLs, eviction, and hit-ratio checks7879**Parameters:**80- `key` (string): Cache key81- `ttl` (string): TTL seconds8283**Commands:**84- `redis-cli SET api:users:42 '{"id":42}' EX 300`85- `redis-cli GET api:users:42`86- `redis-cli TTL api:users:42`87- `redis-cli INFO stats | grep -E 'keyspace_hits|keyspace_misses'`88- `redis-cli --scan --pattern 'api:*' | head -20`8990**Examples:**91- redis-cli SET api:users:42 '{"id":42}' EX 300 && redis-cli TTL api:users:4292- redis-cli INFO stats | grep -E 'keyspace_hits|keyspace_misses'93- redis-cli --scan --pattern 'api:*' | head -209495### conditional-requests96Implement ETag and If-None-Match conditional responses9798**Parameters:**99- `url` (string): Endpoint URL100- `etag` (string): ETag value101102**Commands:**103- `curl -s -D - http://localhost:3000/api/users/42 | grep -i etag`104- `curl -s -H 'If-None-Match: "etag123"' -o /dev/null -w '%{http_code}' http://localhost:3000/api/users/42`105- `node -e "const c=require('crypto');const h=c.createHash('sha1').update(JSON.stringify({id:42})).digest('hex');console.log('ETag: \"'+h+'\"')"`106- `curl -s -H 'If-None-Match: *' -o /dev/null -w '%{http_code}' -X PUT http://localhost:3000/api/users/42 -d '{}'`107- `curl -s -D - http://localhost:3000/api/users/42 | grep -i -E 'etag|cache-control'`108109**Examples:**110- curl -s -H 'If-None-Match: "etag123"' -o /dev/null -w '%{http_code}' http://localhost:3000/api/users/42111- node -e "const c=require('crypto');const h=c.createHash('sha1').update(JSON.stringify({id:42})).digest('hex');console.log('ETag: \"'+h+'\"')"112- curl -s -D - http://localhost:3000/api/users/42 | grep -i -E 'etag|cache-control'113114## References115- [Redis Commands](https://redis.io/docs/latest/commands/)116- [ETag Conditional Requests](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/ETag)