npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

n8n-nodes-redis-anyway

v0.2.0

Published

A Redis cache management plugin for n8n with intelligent cache handling and proactive renewal

Readme

n8n-nodes-redis-anyway

npm version License: MIT

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)

  1. Go to Settings > Community Nodes in your n8n instance
  2. Click Install
  3. Enter n8n-nodes-redis-anyway
  4. 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

  1. In n8n, go to Credentials > Add Credential
  2. Select Redis
  3. 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:

  1. Valid Cache: Data exists and is fresh
  2. Invalid Cache: Data missing or expired
  3. 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:

  1. Report Issues: Use GitHub Issues for bugs and feature requests
  2. Submit PRs: Fork, create a feature branch, and submit a pull request
  3. Improve Documentation: Help us make the docs even better
  4. 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

🔗 Links


Star this repository if it helps your workflow!