Redis Object Cache Pro
Advanced Redis-based object caching for WordPress.
Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/drlaravel/redis-object-cache-pro/archive/refs/heads/main.zipA robust and advanced Redis-based object caching solution for WordPress, designed to boost performance by reducing database queries through efficient caching.
Description
Redis Object Cache Pro is a high-performance WordPress plugin that replaces the default WordPress object cache with a Redis-backed solution. By leveraging Redis, an in-memory data store, it significantly improves site speed and scalability by caching database queries, transients, and other objects. This plugin is ideal for high-traffic WordPress sites or those requiring optimized performance.
Key Features
- Redis Integration: Seamlessly connects to Redis for fast, in-memory caching.
- Drop-in Replacement: Automatically manages the
object-cache.phpdrop-in file for easy setup. - Admin Interface: Configure Redis settings (host, port, auth, database) and view cache statistics from the WordPress admin dashboard.
- WP-CLI Support: Commands like
wp redis statusandwp redis flushfor managing the cache via the command line. - Error Handling: Graceful fallback to WordPress's default caching when Redis is unavailable.
- Multisite Support: Handles blog-specific cache keys in multisite environments.
- Internationalization: Fully translatable with the
redis-object-cache-protext domain.
Benefits
- Improved Performance: Reduces database load by caching objects in Redis, leading to faster page loads.
- Scalability: Handles high-traffic sites efficiently with Redis's in-memory storage.
- Easy Configuration: User-friendly admin settings and automatic drop-in management.
- Developer-Friendly: Extensible with hooks (
wp_redis_check_client_dependencies_callback, etc.) and WP-CLI commands. - Reliable Fallback: Ensures site functionality even if Redis is temporarily unavailable.
Developed by Mohsen Hashempour, this plugin is open-source and available on GitHub.
Installation
-
Upload the Plugin:
- Download the plugin zip file.
- Upload the
redis-object-cache-profolder to the/wp-content/plugins/directory via FTP, or use the WordPress admin interface to upload and install the zip file.
-
Activate the Plugin:
- Go to the WordPress admin dashboard, navigate to Plugins, and activate Redis Object Cache Pro.
-
Configure Redis Settings:
- Navigate to Settings > Redis Cache in the WordPress admin dashboard.
- Enter your Redis server details (host, port, authentication, database, etc.).
- Save the settings to connect to your Redis server.
-
Verify Installation:
- Check the Redis Cache settings page to view the connection status and cache statistics.
- Use WP-CLI (if installed): Run
wp redis statusto confirm the connection.
Note: Ensure a Redis server is running and accessible. The PHPRedis PHP extension (or Relay, if configured) must be installed on your server.
Usage
Admin Interface
- Go to Settings > Redis Cache to:
- Configure Redis connection settings (host, port, auth, database, timeout, retry interval, default expire time).
- View cache statistics (hits, misses, memory usage, uptime, etc.).
- Flush the cache with a single click.
WP-CLI Commands
If WP-CLI is installed, you can use the following commands:
wp redis status: Displays Redis connection details and cache statistics.wp redis flush: Clears the entire Redis cache.
Configuration via wp-config.php
You can override settings by defining constants in wp-config.php:
define('WP_CACHE_KEY_SALT', 'your_unique_salt');
define('WP_REDIS_USE_CACHE_GROUPS', true);
define('WP_REDIS_DEFAULT_EXPIRE_SECONDS', 3600);
define('WP_REDIS_IGNORE_GLOBAL_GROUPS', ['group1', 'group2']);
define('WP_REDIS_DISABLE_FAILBACK_FLUSH', true);
Advanced Customization
Developers can use the following hooks to extend functionality:
wp_redis_check_client_dependencies_callback: Customize dependency checks.wp_redis_prepare_client_connection_callback: Modify Redis client connection logic.wp_redis_perform_client_connection_callback: Adjust Redis authentication/database selection.wp_redis_retry_exception_messages: Customize retryable Redis exception messages.
Requirements
- WordPress 5.0 or higher
- PHP 7.2 or higher
- PHPRedis extension (or Relay, if
WP_REDIS_USE_RELAYis defined) - Redis server (local or remote)
Frequently Asked Questions
Why use Redis for object caching?
Redis is an in-memory key-value store that is significantly faster than disk-based caching. It reduces database queries, speeding up your WordPress site.
What happens if Redis is unavailable?
The plugin falls back to WordPress's default in-memory caching and logs an admin notice. It also supports retrying Redis connections for transient errors.
Can I use this in a multisite setup?
Yes, the plugin fully supports WordPress multisite, with proper handling of blog-specific cache keys.
Contributing
Contributions are welcome! Please submit pull requests or issues on the GitHub repository.
License
This plugin is licensed under the GNU General Public License v2.0 or later.
See the LICENSE file for details.
Credits
Developed by Mohsen Hashempour (Codnama).
Source code: GitHub.
Changelog
1.0.0
- Initial release with Redis object caching, admin settings, WP-CLI support, and multisite compatibility.