Install command
Provided
Automatically clears relevant Redis cache keys when data model files are modified.
Open the source and read safety notes before installing.
Source-backed facts for citing this resource, derived directly from the registry — also available as plain text for AI assistants.
Decision playbook
Signals are present but mixed. Use the checklist below to confirm the source and operational safety for your environment.
0
78
—
No baseline selected
No major trust-signal divergence detected in the current selection.
Confirm ownership and provenance before trusting install instructions.
Source link availableRequired
Open the canonical repository and verify ownership.
Source provenance statusRequired
Marked as source-backed.
Metadata reviewed
Registry metadata indicates a reviewed listing.
Validate risk disclosures before installation or API wiring.
Safety notes presentRequired
Review the listed safety guidance before running commands.
Privacy notes presentRequired
Review data handling notes before connecting accounts or secrets.
Trust level risk gateRequired
Trust level does not block evaluation.
Check package metadata and artifact integrity signals.
Install payload available
Install or copy payload is available for review.
Package verification flag
No package verification flag provided.
Checksum metadata
No checksum provided for downloaded artifact.
Use compare context to validate trade-offs before adoption.
Compare tray has multiple entries
Add at least one more entry to compare trust differences.
Baseline comparison available
No baseline peer selected yet.
Diverging trust signals identified
No major trust-signal divergence found.
Setup at a glance
Copy-ready — paste the snippet to get started.
Install command
Provided
Config snippet
Provided
Copy snippet
Provided
Prerequisites
None
Platforms
1 listed
Difficulty
0/100
Adoption plan
Current risk score 16/100. Use staged verification before broader rollout.
Validate source and review signals before any execution.
Confirm source provenanceRequired
Source URL/provenance metadata is present.
Confirm metadata review state
Listing has review metadata.
Verify install payload
Install/config payload exists and can be inspected.
Confirm safety, privacy, and package integrity signals.
Review safety notesRequired
Safety notes are present.
Review privacy notesRequired
Privacy notes are present.
Verify package integrity metadata
No package verification/checksum metadata.
Adopt in controlled steps based on the selected plan.
Run in isolated sandbox firstRequired
Use a constrained sandbox and observe behavior across multiple tasks.
Roll out graduallyRequired
Roll out to a small cohort before wider usage.
Set monitoring and fallback
Define rollback path and monitor errors after adoption.
Evidence readiness
Required evidence gates are covered (5/6 signals complete).
Source repository/provenance is listed.
Required in this preset
Review metadata is present.
Required in this preset
Safety notes are present.
Required in this preset
Privacy notes are present.
Optional in this preset
Package integrity metadata is missing.
Optional in this preset
Install payload is available.
Required in this preset
Required evidence gates are covered for this preset.
Decision timeline
5/6 steps complete with no blocking gaps for this preset.
triage
Source/provenance metadata is available.
triage
Review metadata is available.
verify
Safety notes are available.
verify
Privacy notes are available.
verify
Package integrity metadata is missing.
rollout
Install payload is available.
No required blockers for this timeline preset.
Safety & privacy surface
1 safety and 1 privacy notes across 2 risk areas. Review closely: credentials & tokens, permissions & scopes.
#!/bin/bash
# Read the tool input from stdin
INPUT=$(cat)
TOOL_NAME=$(echo "$INPUT" | jq -r '.tool_name')
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // .tool_input.path // ""')
if [ -z "$FILE_PATH" ]; then
exit 0
fi
echo "🔄 Redis Cache Invalidator - Analyzing file changes..."
echo "📄 File: $FILE_PATH"
# Check if this is a model or data file that should trigger cache invalidation
if [[ "$FILE_PATH" == *models/*.js ]] || [[ "$FILE_PATH" == *models/*.py ]] || [[ "$FILE_PATH" == *models/*.ts ]] || [[ "$FILE_PATH" == *schemas/*.* ]] || [[ "$FILE_PATH" == *entities/*.* ]]; then
MODEL_NAME=$(basename "${FILE_PATH%.*}")
echo "📊 Model detected: $MODEL_NAME"
# Check if Redis CLI is available
if ! command -v redis-cli >/dev/null 2>&1; then
echo "⚠️ redis-cli not found - please install Redis CLI tools"
echo "💡 Install with: apt-get install redis-tools (Ubuntu) or brew install redis (macOS)"
exit 0
fi
# Test Redis connection
if ! redis-cli ping >/dev/null 2>&1; then
echo "⚠️ Redis server not accessible - skipping cache invalidation"
echo "💡 Ensure Redis server is running and accessible"
exit 0
fi
echo "🔍 Scanning for cache keys related to: $MODEL_NAME"
# Find cache keys related to this model
CACHE_KEYS=$(redis-cli --scan --pattern "*${MODEL_NAME}*" 2>/dev/null)
if [ -n "$CACHE_KEYS" ]; then
KEY_COUNT=$(echo "$CACHE_KEYS" | wc -l)
echo "🗑️ Found $KEY_COUNT cache keys to invalidate:"
# Show first few keys for confirmation
echo "$CACHE_KEYS" | head -5 | while read -r key; do
echo " • $key"
done
if [ "$KEY_COUNT" -gt 5 ]; then
echo " ... and $((KEY_COUNT - 5)) more keys"
fi
# Delete the keys
echo "$CACHE_KEYS" | xargs -r redis-cli DEL >/dev/null 2>&1
echo "✅ Invalidated $KEY_COUNT cache keys for model: $MODEL_NAME"
else
echo "ℹ️ No cache keys found for model: $MODEL_NAME"
fi
# Additional patterns to check
echo "🔍 Checking additional cache patterns..."
# Check for API route caches
API_KEYS=$(redis-cli --scan --pattern "api:*${MODEL_NAME}*" 2>/dev/null)
if [ -n "$API_KEYS" ]; then
API_COUNT=$(echo "$API_KEYS" | wc -l)
echo "$API_KEYS" | xargs -r redis-cli DEL >/dev/null 2>&1
echo "✅ Invalidated $API_COUNT API cache keys"
fi
# Check for query result caches
QUERY_KEYS=$(redis-cli --scan --pattern "query:*${MODEL_NAME}*" 2>/dev/null)
if [ -n "$QUERY_KEYS" ]; then
QUERY_COUNT=$(echo "$QUERY_KEYS" | wc -l)
echo "$QUERY_KEYS" | xargs -r redis-cli DEL >/dev/null 2>&1
echo "✅ Invalidated $QUERY_COUNT query cache keys"
fi
# Check current Redis stats
echo ""
echo "📊 Redis Cache Statistics:"
TOTAL_KEYS=$(redis-cli DBSIZE 2>/dev/null || echo "unknown")
MEMORY_USAGE=$(redis-cli INFO memory 2>/dev/null | grep used_memory_human | cut -d: -f2 | tr -d '\r' || echo "unknown")
echo " • Total keys: $TOTAL_KEYS"
echo " • Memory usage: $MEMORY_USAGE"
echo ""
echo "💡 Cache Invalidation Tips:"
echo " • Use consistent cache key naming patterns"
echo " • Consider cache TTL for automatic expiration"
echo " • Monitor cache hit/miss ratios"
echo " • Use Redis keyspace notifications for advanced invalidation"
echo ""
echo "🎯 Cache invalidation complete!"
elif [[ "$FILE_PATH" == *config/*.* ]] || [[ "$FILE_PATH" == *.env ]]; then
echo "⚙️ Configuration file detected - consider full cache flush if needed"
echo "💡 Run 'redis-cli FLUSHDB' manually if configuration affects cached data"
else
echo "ℹ️ File does not require cache invalidation: $FILE_PATH"
fi
exit 0{
"hooks": {
"postToolUse": {
"script": "./.claude/hooks/redis-cache-invalidator.sh",
"matchers": [
"write",
"edit"
]
}
}
}.claude/settings.local.json~/.claude/settings.json.claude/settings.json{
"hooks": {
"postToolUse": {
"script": "./.claude/hooks/redis-cache-invalidator.sh",
"matchers": ["write", "edit"]
}
}
}
#!/bin/bash
# Read the tool input from stdin
INPUT=$(cat)
TOOL_NAME=$(echo "$INPUT" | jq -r '.tool_name')
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // .tool_input.path // ""')
if [ -z "$FILE_PATH" ]; then
exit 0
fi
echo "🔄 Redis Cache Invalidator - Analyzing file changes..."
echo "📄 File: $FILE_PATH"
# Check if this is a model or data file that should trigger cache invalidation
if [[ "$FILE_PATH" == *models/*.js ]] || [[ "$FILE_PATH" == *models/*.py ]] || [[ "$FILE_PATH" == *models/*.ts ]] || [[ "$FILE_PATH" == *schemas/*.* ]] || [[ "$FILE_PATH" == *entities/*.* ]]; then
MODEL_NAME=$(basename "${FILE_PATH%.*}")
echo "📊 Model detected: $MODEL_NAME"
# Check if Redis CLI is available
if ! command -v redis-cli >/dev/null 2>&1; then
echo "⚠️ redis-cli not found - please install Redis CLI tools"
echo "💡 Install with: apt-get install redis-tools (Ubuntu) or brew install redis (macOS)"
exit 0
fi
# Test Redis connection
if ! redis-cli ping >/dev/null 2>&1; then
echo "⚠️ Redis server not accessible - skipping cache invalidation"
echo "💡 Ensure Redis server is running and accessible"
exit 0
fi
echo "🔍 Scanning for cache keys related to: $MODEL_NAME"
# Find cache keys related to this model
CACHE_KEYS=$(redis-cli --scan --pattern "*${MODEL_NAME}*" 2>/dev/null)
if [ -n "$CACHE_KEYS" ]; then
KEY_COUNT=$(echo "$CACHE_KEYS" | wc -l)
echo "🗑️ Found $KEY_COUNT cache keys to invalidate:"
# Show first few keys for confirmation
echo "$CACHE_KEYS" | head -5 | while read -r key; do
echo " • $key"
done
if [ "$KEY_COUNT" -gt 5 ]; then
echo " ... and $((KEY_COUNT - 5)) more keys"
fi
# Delete the keys
echo "$CACHE_KEYS" | xargs -r redis-cli DEL >/dev/null 2>&1
echo "✅ Invalidated $KEY_COUNT cache keys for model: $MODEL_NAME"
else
echo "ℹ️ No cache keys found for model: $MODEL_NAME"
fi
# Additional patterns to check
echo "🔍 Checking additional cache patterns..."
# Check for API route caches
API_KEYS=$(redis-cli --scan --pattern "api:*${MODEL_NAME}*" 2>/dev/null)
if [ -n "$API_KEYS" ]; then
API_COUNT=$(echo "$API_KEYS" | wc -l)
echo "$API_KEYS" | xargs -r redis-cli DEL >/dev/null 2>&1
echo "✅ Invalidated $API_COUNT API cache keys"
fi
# Check for query result caches
QUERY_KEYS=$(redis-cli --scan --pattern "query:*${MODEL_NAME}*" 2>/dev/null)
if [ -n "$QUERY_KEYS" ]; then
QUERY_COUNT=$(echo "$QUERY_KEYS" | wc -l)
echo "$QUERY_KEYS" | xargs -r redis-cli DEL >/dev/null 2>&1
echo "✅ Invalidated $QUERY_COUNT query cache keys"
fi
# Check current Redis stats
echo ""
echo "📊 Redis Cache Statistics:"
TOTAL_KEYS=$(redis-cli DBSIZE 2>/dev/null || echo "unknown")
MEMORY_USAGE=$(redis-cli INFO memory 2>/dev/null | grep used_memory_human | cut -d: -f2 | tr -d '\r' || echo "unknown")
echo " • Total keys: $TOTAL_KEYS"
echo " • Memory usage: $MEMORY_USAGE"
echo ""
echo "💡 Cache Invalidation Tips:"
echo " • Use consistent cache key naming patterns"
echo " • Consider cache TTL for automatic expiration"
echo " • Monitor cache hit/miss ratios"
echo " • Use Redis keyspace notifications for advanced invalidation"
echo ""
echo "🎯 Cache invalidation complete!"
elif [[ "$FILE_PATH" == *config/*.* ]] || [[ "$FILE_PATH" == *.env ]]; then
echo "⚙️ Configuration file detected - consider full cache flush if needed"
echo "💡 Run 'redis-cli FLUSHDB' manually if configuration affects cached data"
else
echo "ℹ️ File does not require cache invalidation: $FILE_PATH"
fi
exit 0
Complete hook script that invalidates Redis cache keys when model files are modified
#!/bin/bash
INPUT=$(cat)
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // .tool_input.path // ""')
if [ -z "$FILE_PATH" ]; then
exit 0
fi
if [[ "$FILE_PATH" == *models/*.js ]] || [[ "$FILE_PATH" == *models/*.ts ]]; then
MODEL_NAME=$(basename "${FILE_PATH%.*}")
if command -v redis-cli >/dev/null 2>&1; then
if redis-cli ping >/dev/null 2>&1; then
CACHE_KEYS=$(redis-cli --scan --pattern "*${MODEL_NAME}*" 2>/dev/null)
if [ -n "$CACHE_KEYS" ]; then
echo "$CACHE_KEYS" | xargs -r redis-cli DEL >/dev/null 2>&1
echo "✅ Invalidated cache keys for: $MODEL_NAME"
fi
fi
fi
fi
exit 0
Complete hook configuration for .claude/settings.json to enable Redis cache invalidation
{
"hooks": {
"postToolUse": {
"script": "./.claude/hooks/redis-cache-invalidator.sh",
"matchers": ["write", "edit"]
}
}
}
Enhanced hook script with multiple cache pattern matching
#!/bin/bash
INPUT=$(cat)
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // .tool_input.path // ""')
if [[ "$FILE_PATH" == *models/* ]]; then
MODEL_NAME=$(basename "${FILE_PATH%.*}")
if command -v redis-cli >/dev/null 2>&1 && redis-cli ping >/dev/null 2>&1; then
echo "🔍 Scanning for cache keys related to: $MODEL_NAME"
redis-cli --scan --pattern "*${MODEL_NAME}*" | while read -r key; do
redis-cli DEL "$key" >/dev/null 2>&1
echo " • Deleted: $key"
done
redis-cli --scan --pattern "api:*${MODEL_NAME}*" | xargs -r redis-cli DEL >/dev/null 2>&1
redis-cli --scan --pattern "query:*${MODEL_NAME}*" | xargs -r redis-cli DEL >/dev/null 2>&1
echo "✅ Cache invalidation complete"
fi
fi
exit 0
Enhanced hook script with Redis pipeline for efficient batch operations
#!/bin/bash
INPUT=$(cat)
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // .tool_input.path // ""')
if [[ "$FILE_PATH" == *models/* ]]; then
MODEL_NAME=$(basename "${FILE_PATH%.*}")
if command -v redis-cli >/dev/null 2>&1 && redis-cli ping >/dev/null 2>&1; then
redis-cli --scan --pattern "*${MODEL_NAME}*" | redis-cli --pipe >/dev/null 2>&1 <<EOF
$(redis-cli --scan --pattern "*${MODEL_NAME}*" | sed 's/^/DEL /')
EOF
echo "✅ Batch cache invalidation complete"
fi
fi
exit 0
Example configuration for Redis cache invalidator settings
{
"redis": {
"host": "localhost",
"port": 6379,
"database": 0,
"patterns": [
"*{model}*",
"api:*{model}*",
"query:*{model}*",
"cache:*{model}*"
],
"timeout": 5,
"retry_attempts": 3
}
}
Install Redis CLI tools using 'apt-get install redis-tools' (Ubuntu/Debian) or 'brew install redis' (macOS). The hook gracefully exits if Redis tools are unavailable. Verify redis-cli installation. Test with various Redis installations.
Verify Redis is running with 'redis-cli ping'. Check connection settings in redis.conf. The hook tests connectivity before attempting invalidation and exits safely if unreachable. Verify Redis connection. Test with various Redis configurations.
Review cache key naming patterns. The hook uses wildcard matching on model names. Use consistent prefixes like 'api:', 'query:', 'model:' for precise pattern matching and control. Verify cache key patterns. Test with various cache key naming conventions.
The hook only processes files in /models/, /schemas/, /entities/ directories. Organize your codebase to match these patterns or customize the path matching logic in the script. Verify file path patterns. Test with various project structures.
Check if your application uses multiple Redis databases (DB0, DB1, etc.) or instances. The hook targets the default database. Use 'redis-cli -n ' to verify which database stores your cache. Verify Redis database selection. Test with various Redis database configurations.
SCAN can be slow with millions of keys. Use cursor-based scanning with SCAN cursor COUNT option. Consider using Redis keyspace notifications for event-driven invalidation. Optimize cache key patterns. Test with various key set sizes.
Verify Redis user has DEL and SCAN permissions. Check Redis ACL configuration. Ensure Redis connection uses appropriate authentication. Verify Redis permissions. Test with various Redis permission configurations.
Hook targets single Redis instance. For clusters, use Redis Cluster mode with redis-cli --cluster option. For multiple instances, configure hook to iterate through instances. Verify Redis topology. Test with various Redis configurations.
Redis Cache Invalidator - Hooks side by side with 3 alternatives on trust, install, platform support, and disclosed safety notes — all from reviewed registry metadata.
Next steps differ across entries — use the actions in the table below to copy install commands and source links per resource.
| Field | Automatically clears relevant Redis cache keys when data model files are modified. Open dossier | Detects unused CSS selectors when stylesheets are modified to keep CSS lean using PurgeCSS, PostCSS, and content analysis. This hook runs on CSS/SCSS file write/edit operations and analyzes stylesheets to identify unused selectors, generate optimized output, and report before/after size metrics. Open dossier | A PostToolUse hook that reminds you to enable native query logging for PostgreSQL, Prisma, Sequelize, and TypeORM, and flags possible N+1 patterns when you edit SQL or data-access files. Open dossier | Alerts when files exceed size thresholds that could impact performance. This PostToolUse hook provides comprehensive file size monitoring when files are created or modified, automatically detecting files that exceed recommended size thresholds for different file types and providing optimization suggestions. Open dossier |
|---|---|---|---|---|
| Next stepsDiffers | ||||
| Trust | ||||
| Review status | ReviewedMaintainer reviewed | ReviewedMaintainer reviewed | ReviewedMaintainer reviewed | ReviewedMaintainer reviewed |
| Package trust | Package not verified | Package not verified | Package not verified | Package not verified |
| Source provenance | Source-backed | Source-backed | Source-backed | Source-backed |
| Submitter | — | — | — | — |
| Install risk | Review first | Review first | Review first | Review first |
| Notes | Safety ✓ Privacy ✓ | Safety ✓ Privacy ✓ | Safety ✓ Privacy ✓ | Safety ✓ Privacy ✓ |
| Brand | — | — | — | |
| Category | hooks | hooks | hooks | hooks |
| Source | source-backed | source-backed | source-backed | source-backed |
| Author | JSONbored | JSONbored | JSONbored | JSONbored |
| Added | 2025-09-19 | 2025-09-19 | 2025-10-19 | 2025-09-19 |
| Platforms | Claude Code | Claude Code | Claude Code | Claude Code |
| Source repo | — | — | — | — |
| Safety notes | ✓Runs automatically on its configured Claude Code hook event and executes shell logic that can read, modify, or delete files in your project (and may run builds, installs, or network calls); review the script and scope it to expected paths before enabling. | ✓Runs automatically on its configured Claude Code hook event and executes shell logic that can read, modify, or delete files in your project (and may run builds, installs, or network calls); review the script and scope it to expected paths before enabling. | ✓Runs automatically after bash, write, or edit activity and inspects files that look like query, model, repository, DAO, or SQL files. Creates .claude/logs/query-performance.log and appends database command or file-analysis events. Uses grep-based heuristics for query warnings and should not be treated as proof of a performance defect. | ✓Runs automatically on its configured Claude Code hook event and executes shell logic that can read, modify, or delete files in your project (and may run builds, installs, or network calls); review the script and scope it to expected paths before enabling. |
| Privacy notes | ✓Receives Claude Code hook input (session metadata, file paths, and tool output) and reads local project files; review what the script logs or forwards to external services and keep credentials out of its output. | ✓Receives Claude Code hook input (session metadata, file paths, and tool output) and reads local project files; review what the script logs or forwards to external services and keep credentials out of its output. | ✓Reads query-related source files and may print file paths, query patterns, and database command strings to local hook output. Stores analyzed file paths and database command text in .claude/logs/query-performance.log. Database command text may include connection names, database names, or other operational details if typed directly into the command. | ✓Receives Claude Code hook input (session metadata, file paths, and tool output) and reads local project files; review what the script logs or forwards to external services and keep credentials out of its output. |
| Prerequisites | — none listed | — none listed | — none listed | — none listed |
| Install | | | — | |
| Config | | | | |
| Citations | ||||
| Claim | Unclaimed | Unclaimed | Unclaimed | Unclaimed |
Source-backed guides for putting this to work.
Control MCP tool output size with env limits, annotations, and tool search to protect Claude Code context.
Loading live community signals…
A short, calm digest of reviewed Claude resources. Unsubscribe any time.