Package Information
Documentation
n8n-nodes-redis-anyway
A comprehensive Redis integration for n8n that provides intelligent cache management with automatic renewal capabilities, database selection, and advanced data manipulation features.
⨠Features
- šÆ Smart Cache Management: Store, retrieve, and manipulate cached data with intelligent expiration handling
- š Automatic Cache Renewal: Proactive cache refresh based on configurable thresholds
- šļø Database Selection: Support for Redis databases 0-15 with credential-level configuration
- š Multiple Data Types: Support for strings, JSON objects, and Redis hashes
- š§ Advanced Manipulation: Partial updates, array operations, and field-level modifications
- ā” Async Connection Handling: Reliable connection management with proper ready-state checking
- š”ļø Error Resilience: Robust error handling and connection retry mechanisms
š Quick Start
Installation
Via n8n Community Nodes (Recommended)
- Go to Settings > Community Nodes in your n8n instance
- Click Install
- Enter
n8n-nodes-redis-anyway - Click Install
Manual Installation
# Clone the repository
git clone https://github.com/matheuskindrazki/n8n-redis-anyway.git
cd n8n-redis-anyway
# Install dependencies
pnpm install
# Build the package
pnpm build
# Copy to n8n custom nodes directory
cp -r dist ~/.n8n/custom/
Redis Credentials Setup
- In n8n, go to Credentials > Add Credential
- Select Redis
- Configure your connection:
Host: your-redis-host # e.g., localhost, redis.example.com
Port: 6379 # Default Redis port
Database: 0 # Redis database number (0-15)
Username: your-username # Optional (Redis 6.0+)
Password: your-password # Optional
Use TLS/SSL: false # Enable for secure connections
š¦ Available Nodes
1. Redis Set Cache
Store data in Redis with configurable expiration and data type support.
Supported Data Types:
- String: Simple text or numeric values
- JSON: Complex objects and arrays
- Hash: Key-value field collections
Configuration:
Key: "user:123:profile" # Unique identifier
Data Type: "json" # string, json, or hash
Value: '{"name":"John","age":30}' # Data to store
Expiration: 3600 # Seconds (0 = never expires)
Example Flow:
[HTTP Request] ā [Redis Set Cache] ā [Continue Workflow]
2. Redis Get Cache
Retrieve cached data with intelligent expiration detection and renewal triggers.
Configuration:
Key: "user:123:profile" # Key to retrieve
Renewal Threshold: 300 # Seconds before expiration to trigger renewal
Three Output Paths:
- Valid Cache: Data exists and is fresh
- Invalid Cache: Data missing or expired
- Needs Renewal: Data exists but approaching expiration
Smart Caching Flow Example:
[Trigger] ā [Redis Get Cache]
āā Valid Cache ā [Use Data] ā [Response]
āā Invalid Cache ā [Fetch from API] ā [Redis Set Cache] ā [Response]
āā Needs Renewal ā [Background Refresh] ā [Redis Set Cache]
āā [Use Current Data] ā [Response]
3. Redis Manipulate Cache
Perform partial updates on existing cached data without full replacement.
Operations:
- Update JSON Field: Modify specific object properties
- Update Hash Field: Change individual hash fields
- Append to JSON Array: Add items to arrays
- Remove from JSON Array: Remove items from arrays
Configuration:
Key: "user:123:profile" # Target key
Operation: "updateJsonField" # Type of manipulation
Field Path: "user.preferences" # Dot notation for nested fields
New Value: '{"theme":"dark"}' # New value (JSON or string)
Preserve TTL: true # Maintain original expiration
š§ Advanced Configuration
Database Selection
Redis supports multiple databases (0-15). Configure this in your Redis credentials:
Database: 4 # Your cached data will be stored in database 4
Verification:
# Connect to specific database and verify
redis-cli -h your-host -p 6379 -n 4 KEYS "*"
Connection Options
The plugin automatically configures optimal connection settings:
{
maxRetriesPerRequest: 1, // Prevent multiple retries per operation
connectTimeout: 15000, // 15-second connection timeout
commandTimeout: 10000, # 10-second command timeout
enableOfflineQueue: false, # Fail fast when disconnected
enableReadyCheck: true, # Wait for ready state
}
šļø Development & Testing
Local Development Setup
# Clone and setup
git clone https://github.com/matheuskindrazki/n8n-redis-anyway.git
cd n8n-redis-anyway
pnpm install
# Development workflow
pnpm build # Build the package
pnpm test # Run tests (if available)
pnpm lint # Check code quality
Docker Testing Environment
We provide a complete testing environment with Docker:
# Make script executable
chmod +x scripts/test-environment.sh
# Start n8n + Redis environment
./scripts/test-environment.sh start
# Access n8n at http://localhost:5678
# Redis credentials: host=redis, port=6379
# Rebuild after changes
./scripts/test-environment.sh rebuild
# Stop environment
./scripts/test-environment.sh stop
š Troubleshooting
Common Issues
1. "Stream isn't writeable" Error
Solution: Update to latest version. We've implemented async connection handling that waits for the Redis connection to be fully ready.
2. "SECURITY ATTACK detected" in Redis Logs
Solution: This was caused by HTTP-based connection testing. Fixed in latest version by removing problematic connection tests.
3. Data Writing to Wrong Database
Solution: Ensure the Database field is set in your Redis credentials. The plugin now properly respects database selection.
4. Connection Timeouts
Solution: Check your Redis server accessibility and credentials. The plugin includes comprehensive retry logic and timeout handling.
Debug Information
Enable debug logging to troubleshoot connection issues:
// Connection logs will show:
Redis connection options: {
host: "your-host",
port: 6379,
db: 4, // Database number
username: "(set)",
password: "(set)",
tls: "(disabled)"
}
š Use Cases & Examples
1. API Response Caching
# Workflow: Cache API responses with smart refresh
Trigger ā Get Cache ā Valid? ā Return Cached Data
ā Invalid? ā Call API ā Set Cache ā Return Fresh Data
ā Renewal? ā Background API Call ā Update Cache
ā Return Current Data
2. User Session Management
# Store user sessions with automatic cleanup
User Login ā Set Cache (key: "session:user123", expiration: 3600)
Page Request ā Get Cache ā Valid? ā Continue
ā Invalid? ā Redirect to Login
3. Real-time Data Aggregation
# Accumulate data with partial updates
New Event ā Manipulate Cache (operation: "appendJsonArray")
Dashboard ā Get Cache ā Display Aggregated Data
4. Multi-Environment Data Isolation
# Use different databases for environments
Development: Database 0
Staging: Database 1
Production: Database 2
Cache Analytics: Database 3
š¤ Contributing
We welcome contributions! Please feel free to:
- Report Issues: Use GitHub Issues for bugs and feature requests
- Submit PRs: Fork, create a feature branch, and submit a pull request
- Improve Documentation: Help us make the docs even better
- Share Use Cases: Tell us how you're using the plugin
Development Guidelines
- Follow TypeScript best practices
- Include tests for new features
- Update documentation for changes
- Use conventional commits
š Changelog
Latest Release
- ā Database Selection: Full support for Redis databases 0-15
- ā Async Connection Handling: Eliminates "Stream isn't writeable" errors
- ā Security Fix: Removed problematic HTTP connection tests
- ā Enhanced Error Handling: Better error messages and retry logic
- ā Improved Logging: Detailed connection and operation information
š License
MIT License - see LICENSE.md for details.
šØāš» Author
Matheus Kindrazki
- Email: matheus@kindrazki.dev
- GitHub: @matheuskindrazki
š Links
ā Star this repository if it helps your workflow!