### Install WordPress PHPUnit Test Suite Source: https://github.com/pantheon-systems/wp-redis/blob/main/CONTRIBUTING.md Command to set up the WordPress PHPUnit test suite locally. Requires a database named 'wordpress_test' and the PHPRedis extension enabled. ```bash bash bin/install-wp-tests.sh wordpress_test root "" localhost ``` -------------------------------- ### Prepare Behat Tests Source: https://github.com/pantheon-systems/wp-redis/blob/main/CONTRIBUTING.md Shell script to prepare the Pantheon site for Behat testing. Requires Terminus installation and specific environment variables to be set. ```bash ./bin/behat-prepare.sh ``` -------------------------------- ### WP-CLI Command: `wp redis info` Source: https://github.com/pantheon-systems/wp-redis/blob/main/readme.txt Illustrates the use of the `wp redis info` command to get Redis statistics. ```bash # Display high-level Redis statistics wp redis info ``` -------------------------------- ### WP Redis Object Cache Drop-in Source: https://github.com/pantheon-systems/wp-redis/blob/main/readme.txt Instructions for installing the WP Redis object cache drop-in file, `object-cache.php`, into the `wp-content/` directory. This can be done via a symlink or by copying the file, enabling Redis as the object cache backend for WordPress. ```bash # Install object-cache.php to wp-content/object-cache.php with a symlink or by copying the file. ``` -------------------------------- ### Unique Cache Key Salt Source: https://github.com/pantheon-systems/wp-redis/blob/main/README.md Define a unique salt for each WordPress install to use the same Redis server with multiple discreet installations. This prevents key collisions. ```php define( 'WP_CACHE_KEY_SALT', 'your_unique_salt_here' ); ``` -------------------------------- ### WP Redis Configuration Constants Source: https://github.com/pantheon-systems/wp-redis/blob/main/readme.txt Allows for advanced configuration of WP Redis using PHP constants defined in wp-config.php. This includes enabling cache groups, using Relay as a client, and defining a unique salt for cache keys across multiple WordPress installs. ```php define( 'WP_REDIS_USE_CACHE_GROUPS', true ); ``` ```php define( 'WP_REDIS_USE_RELAY', true ); ``` ```php define( 'WP_CACHE_KEY_SALT', 'your_unique_salt_here' ); ``` -------------------------------- ### WP Redis Multisite SQL Error Prevention Source: https://github.com/pantheon-systems/wp-redis/blob/main/readme.txt This bug fix prevents a SQL error that could occur in multisite installations when the `$wpdb->options` table is not yet initialized. ```php $wpdb->options ``` -------------------------------- ### Automated Deployments with GitHub Actions Source: https://github.com/pantheon-systems/wp-redis/blob/main/README.md Adds CONTRIBUTING.md and a GitHub Action to automate deployments to wp.org. This improves the release workflow. ```YAML name: Deploy to WordPress.org on: push: tags: ["*"] jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Deploy to WordPress.org uses: ahmadnassri/action-wordpress-plugin-deploy@v1 env: WP_USERNAME: ${{ secrets.WP_USERNAME }} WP_PASSWORD: ${{ secrets.WP_PASSWORD }} SLUG: wp-redis ``` -------------------------------- ### WP-CLI Command: `wp redis cli` Source: https://github.com/pantheon-systems/wp-redis/blob/main/readme.txt Demonstrates the usage of the `wp redis cli` command to launch `redis-cli` with the correct credentials. ```bash # Launch redis-cli with WordPress' Redis credentials wp redis cli ``` -------------------------------- ### WP-CLI Command: `wp redis enable` Source: https://github.com/pantheon-systems/wp-redis/blob/main/readme.txt Demonstrates enabling the Redis object cache by creating the necessary symlink. ```bash # Create the object-cache.php symlink to enable Redis caching wp redis enable ``` -------------------------------- ### Release Branch Workflow Source: https://github.com/pantheon-systems/wp-redis/blob/main/CONTRIBUTING.md Git commands for creating a release branch, making release commits, and preparing the next development version. ```git git checkout main git checkout -b release_X.Y.Z # Update version numbers in README.md, readme.txt, wp-redis.php # Add date to changelog headings git commit -m "Release X.Y.Z" git push origin release_X.Y.Z ``` ```git git checkout release git pull origin release git checkout main git rebase release # Update version numbers to X.Y.X-dev # Add new X.Y.X-dev changelog heading git add -A . git commit -m "Prepare X.Y.X-dev" git push origin main ``` -------------------------------- ### WP-CLI Redis Commands Source: https://github.com/pantheon-systems/wp-redis/blob/main/README.md Introduces new WP-CLI commands for interacting with Redis: `wp redis debug` for cache hit/miss ratio, `wp redis info` for statistics, and `wp redis enable` for creating the object-cache.php symlink. ```WP-CLI wp redis debug --url=example.com wp redis info wp redis enable ``` -------------------------------- ### WP Redis Command Line Interface Source: https://github.com/pantheon-systems/wp-redis/blob/main/README.md Introduces `wp redis-cli`, a WP-CLI command to launch `redis-cli` with WordPress' Redis credentials. This provides a convenient way to interact with Redis directly from the command line within the WordPress environment. ```WP-CLI wp redis-cli ``` -------------------------------- ### WP-CLI Redis Commands Source: https://github.com/pantheon-systems/wp-redis/blob/main/README.md This section details the available WP-CLI commands for managing the WP Redis object cache. These commands allow for launching redis-cli, debugging cache performance, enabling the object cache, and retrieving connection information. ```bash $ wp help redis NAME wp redis SYNOPSIS wp redis SUBCOMMANDS cli Launch redis-cli using Redis configuration for WordPress debug Debug object cache hit / miss ratio for any page URL. enable Enable WP Redis by creating the symlink for object-cache.php info Provide details on the Redis connection. Use `wp help redis ` to learn more about each command. ``` -------------------------------- ### WP-CLI Redis Commands Source: https://github.com/pantheon-systems/wp-redis/blob/main/readme.txt This section details the available WP-CLI commands for interacting with Redis, including debugging, information retrieval, and enabling the object cache. ```APIDOC wp redis debug - Displays cache hit/miss ratio for any URL. wp redis info - Displays high-level Redis statistics. wp redis enable - Creates the object-cache.php symlink. wp redis-cli - Launches redis-cli with WordPress' Redis credentials. - Parameters: - key: The sorted set key - member: Members to remove - Returns: Number of members removed ``` -------------------------------- ### WP-CLI Commands for WP Redis Source: https://github.com/pantheon-systems/wp-redis/blob/main/readme.txt Provides a set of WP-CLI commands for managing and interacting with the WP Redis object cache. These commands include launching redis-cli, debugging cache performance, enabling the object-cache.php drop-in, and displaying connection information. ```bash $ wp help redis ``` ```bash $ wp redis cli ``` ```bash $ wp redis debug ``` ```bash $ wp redis enable ``` ```bash $ wp redis info ``` -------------------------------- ### Composer Dependencies and License Source: https://github.com/pantheon-systems/wp-redis/blob/main/README.md Removes Grunt and adds a valid license to the Composer file. Updates Composer dependencies to ensure the project uses up-to-date libraries. ```PHP composer update ``` -------------------------------- ### Error Handling and Fallbacks Source: https://github.com/pantheon-systems/wp-redis/blob/main/readme.txt Code snippets demonstrating error handling, such as bailing early on Redis connection exceptions and falling back to `$_SERVER`. ```php // Bail early when connecting to Redis throws an Exception try { // Redis connection logic } catch ( Exception $e ) { // Handle exception, e.g., log error and continue without Redis } // Fall back to $_SERVER in wp_redis_get_info() function wp_redis_get_info() { if ( isset( $_SERVER['REDIS_INFO'] ) ) { return $_SERVER['REDIS_INFO']; } // Other logic } // Catch exceptions when trying to connect to Redis ``` -------------------------------- ### WP-CLI Command: `wp redis debug` Source: https://github.com/pantheon-systems/wp-redis/blob/main/readme.txt Shows how to use the `wp redis debug` command to inspect cache performance. ```bash # Display cache hit/miss ratio for a specific URL wp redis debug --url=example.com ``` -------------------------------- ### Redis Connection and Configuration Source: https://github.com/pantheon-systems/wp-redis/blob/main/readme.txt Code snippets demonstrating how to configure Redis connections and constants for various features like Relay support, ignoring global groups, and default expire times. ```php // Support for Relay via WP_REDIS_USE_RELAY constant if ( defined( 'WP_REDIS_USE_RELAY' ) && WP_REDIS_USE_RELAY ) { // Relay logic } // Ignore global groups with WP_REDIS_IGNORE_GLOBAL_GROUPS constant if ( defined( 'WP_REDIS_IGNORE_GLOBAL_GROUPS' ) && WP_REDIS_IGNORE_GLOBAL_GROUPS ) { // Logic to ignore global groups } // Set default cache expire value with WP_REDIS_DEFAULT_EXPIRE_SECONDS constant if ( defined( 'WP_REDIS_DEFAULT_EXPIRE_SECONDS' ) ) { $default_expire = WP_REDIS_DEFAULT_EXPIRE_SECONDS; } else { $default_expire = 3600; // Default to 1 hour } // Specify Redis database number from environment/server variables $redis_server = [ 'database' => getenv('REDIS_DB') ?: ($_SERVER['REDIS_DB'] ?? 0) ]; // Register specific groups to use Redis hashes wp_cache_add_redis_hash_groups( ['group1', 'group2'] ); ``` -------------------------------- ### Redis Database Number from Environment Variables Source: https://github.com/pantheon-systems/wp-redis/blob/main/README.md Adds support for specifying the Redis database number using environment or server variables. This enhances flexibility in configuring Redis connections. ```PHP $redis_server['database'] = getenv('REDIS_DB') ?: 0; ``` -------------------------------- ### Redis Operations Source: https://github.com/pantheon-systems/wp-redis/blob/main/readme.txt Snippets illustrating Redis operations like flushing databases and handling cache groups. ```php // Use flushdb instead of flushAll to avoid flushing the entire Redis instance // redis_client.flushdb(); // Register specific groups to use Redis hashes wp_cache_add_redis_hash_groups( ['group1', 'group2'] ); ``` -------------------------------- ### Redis Connection Exception Handling Source: https://github.com/pantheon-systems/wp-redis/blob/main/README.md Bails early when connecting to Redis throws an Exception to avoid fatal errors. Also catches exceptions when trying to connect to Redis, improving robustness. ```PHP try { // Attempt to connect to Redis } catch ( Exception $e ) { // Handle connection error gracefully error_log( 'Redis connection failed: ' . $e->getMessage() ); } ``` -------------------------------- ### WP_REDIS_USE_RELAY Constant Source: https://github.com/pantheon-systems/wp-redis/blob/main/README.md Introduces support for Relay via the `WP_REDIS_USE_RELAY` constant. This allows for integration with the Relay caching system. ```PHP define( 'WP_REDIS_USE_RELAY', true ); ``` -------------------------------- ### Cache Functionality Source: https://github.com/pantheon-systems/wp-redis/blob/main/readme.txt Code snippets related to core caching functions like `wp_cache_supports`, `wp_cache_get_multiple`, and handling cache data. ```php // Declare and support features for wp_cache_supports function wp_cache_supports( $feature ) { // Implementation details return true; } // Get multiple cache items $keys = ['key1', 'key2']; $values = wp_cache_get_multiple( $keys ); // Fallback to $_SERVER in wp_redis_get_info() function wp_redis_get_info() { if ( isset( $_SERVER['REDIS_INFO'] ) ) { return $_SERVER['REDIS_INFO']; } // Other logic } // Preserve null values in internal cache // Convert numeric values to their true type when getting ``` -------------------------------- ### Redis Connection Methods Filter Source: https://github.com/pantheon-systems/wp-redis/blob/main/README.md Adds filterable connection methods to permit the use of Predis. This allows for alternative Redis client implementations. ```PHP apply_filters( 'wp_redis_client_class', 'Redis' ); ``` -------------------------------- ### Dependabot Target Branch Source: https://github.com/pantheon-systems/wp-redis/blob/main/README.md Configures Dependabot to target the `develop` branch for pull requests. This streamlines the dependency update process. ```YAML version: 2 updates: - package-ecosystem: "composer" directory: "/" schedule: interval: "daily" target-branch: "develop" ``` -------------------------------- ### Relay Client Configuration Source: https://github.com/pantheon-systems/wp-redis/blob/main/README.md Configure WP Redis to use Relay as the client instead of PhpRedis. For support, use Relay's GitHub discussions. ```php define( 'WP_REDIS_USE_RELAY', true ); ``` -------------------------------- ### Redis Server Configuration Source: https://github.com/pantheon-systems/wp-redis/blob/main/README.md Configure the Redis server connection details in wp-config.php. Supports both TCP/IP and Unix socket connections. Authentication and database selection are also supported. ```php $redis_server = array( 'host' => '127.0.0.1', 'port' => 6379, 'auth' => '12345', // ['user', 'password'] if you use Redis ACL 'database' => 0, // Optionally use a specific numeric Redis database. Default is 0. ); ``` ```php $redis_server = array( 'host' => '/path/of/redis/socket-file.sock', 'port' => null, 'auth' => '12345', 'database' => 0, // Optionally use a specific numeric Redis database. Default is 0. ); ``` -------------------------------- ### PHP 8.2 Support Source: https://github.com/pantheon-systems/wp-redis/blob/main/README.md Adds support for PHP 8.2, ensuring compatibility with the latest PHP versions and leveraging new language features. ```PHP // Code updated to be compatible with PHP 8.2 features and syntax. ``` -------------------------------- ### WP-CLI Command for Transients Source: https://github.com/pantheon-systems/wp-redis/blob/main/README.md Use the WP-CLI command to delete all transients from the options table when migrating to WP Redis. This ensures WP Redis manages the transient cache. ```bash wp transient delete-all ``` -------------------------------- ### Redis CLI Fix Source: https://github.com/pantheon-systems/wp-redis/blob/main/README.md Fixes the `wp redis cli` command by using `proc_open()` directly instead of `WP_CLI::launch()`. This resolves issues with command execution and output handling. ```PHP proc_open('redis-cli ...', $descriptorspec, $pipes); ``` -------------------------------- ### WP Redis Cache Group Support Source: https://github.com/pantheon-systems/wp-redis/blob/main/README.md Introduces opt-in support for Redis cache groups. When enabled, WP Redis persists cache groups in a structured manner, rather than hashing the cache key and group together. This feature enhances organization and management of cached data. ```PHP define( 'WP_REDIS_USE_CACHE_GROUPS', true ); ``` -------------------------------- ### wp_cache_get_multiple Implementation Source: https://github.com/pantheon-systems/wp-redis/blob/main/README.md Implements the `wp_cache_get_multiple()` function for WordPress 5.5. This function allows retrieving multiple cache items efficiently. ```PHP function wp_cache_get_multiple( array $keys, string $group = 'default', array $data = null, &$found = null ) { // Implementation for retrieving multiple cache items... return []; } ``` -------------------------------- ### WP Redis Plugin API Source: https://github.com/pantheon-systems/wp-redis/blob/main/README.md This section outlines the core functions and constants used by the WP Redis plugin for object caching. It includes functions for cache manipulation, group management, and client dependency checks. ```APIDOC wp_cache_add_non_persistent_groups( array $groups ) Description: Prevents specified cache groups from using Redis, falling back to the default runtime object cache. Parameters: $groups: An array of cache group names to exclude from Redis persistence. check_client_dependencies() Description: Checks if the necessary Redis client dependencies are met. Returns: Boolean indicating if dependencies are met. flush_runtime() Description: Clears the local runtime cache. flush_group( string $group ) Description: Clears the cache for a specific group. Parameters: $group: The name of the cache group to flush. ``` -------------------------------- ### Configure Redis Server Connection (PHP) Source: https://github.com/pantheon-systems/wp-redis/blob/main/readme.txt Defines the connection parameters for the Redis server in WordPress's wp-config.php. This includes host, port, authentication, and database selection. It also supports using a socket file for the connection. ```php $redis_server = array( 'host' => '127.0.0.1', 'port' => 6379, 'auth' => '12345', // ['user', 'password'] if you use Redis ACL 'database' => 0, // Optionally use a specific numeric Redis database. Default is 0. ); ``` ```php $redis_server = array( 'host' => '/path/of/redis/socket-file.sock', 'port' => null, 'auth' => '12345', 'database' => 0, // Optionally use a specific numeric Redis database. Default is 0. ); ``` -------------------------------- ### wp_redis_get_info Fallback Source: https://github.com/pantheon-systems/wp-redis/blob/main/README.md Applies logic to fall back to `$_SERVER` in `wp_redis_get_info()` when necessary. This ensures that Redis information can be retrieved even in certain server configurations. ```PHP function wp_redis_get_info() { // ... existing logic ... if ( ! $redis_info ) { // Fallback logic using $_SERVER } // ... } ``` -------------------------------- ### Redis Hashes for Cache Groups Source: https://github.com/pantheon-systems/wp-redis/blob/main/README.md Introduces `wp_cache_add_redis_hash_groups()`, which allows registering specific groups to use Redis hashes. This offers more precise control over caching compared to the `WP_REDIS_USE_CACHE_GROUPS` constant. ```PHP wp_cache_add_redis_hash_groups( ['my_group', 'another_group'] ); ``` -------------------------------- ### Cache Data Order in wp_cache_get_multiple Source: https://github.com/pantheon-systems/wp-redis/blob/main/README.md Fixes faulty logic in `WP_REDIS_IGNORE_GLOBAL_GROUPS` check and ensures cache data is returned in the correct order when using `wp_cache_get_multiple()` and the internal cache is already primed. ```PHP // Ensure correct ordering of returned cache items ``` -------------------------------- ### Redis Database Specification Source: https://github.com/pantheon-systems/wp-redis/blob/main/README.md Allows specifying a Redis database number using the `$redis_server['database']` parameter. This enables the use of different Redis databases for isolation or organization. ```PHP $redis_server = [ 'host' => '127.0.0.1', 'port' => 6379, 'database' => 5 ]; ``` -------------------------------- ### Add Cache Hit/Miss Rate to Footer Source: https://github.com/pantheon-systems/wp-redis/wiki/Home This snippet adds the cache hit and miss rate to the WordPress footer when a user with 'manage_options' capability is logged in. It hooks into the 'wp_footer' action and utilizes the global '$wp_object_cache' object. ```php add_action( 'wp_footer', function () { if ( ! current_user_can( 'manage_options' ) ) { return; } $GLOBALS['wp_object_cache']->stats(); } ); ``` -------------------------------- ### Empty Password for redis-cli Source: https://github.com/pantheon-systems/wp-redis/blob/main/README.md Bug fix to correctly pass an empty password to `redis-cli` when no password is set. This ensures proper authentication handling. ```PHP redis-cli -h host -p port -a '' ``` -------------------------------- ### WP Redis Unix Socket Configuration Source: https://github.com/pantheon-systems/wp-redis/blob/main/readme.txt This bug fix permits the use of a Unix socket in `$redis_server['host']` by ensuring the supplied `$port` is null. This allows for more flexible Redis connection configurations. ```php $redis_server['host'] ``` -------------------------------- ### WP Redis Exception Handling Source: https://github.com/pantheon-systems/wp-redis/blob/main/readme.txt This bug fix enhances WP Redis's robustness by catching Exceptions thrown during authentication. This allows for failing back to the internal object cache if authentication fails. ```php Exceptions ``` -------------------------------- ### Cache Group Configuration Source: https://github.com/pantheon-systems/wp-redis/blob/main/README.md Enable true cache groups for better key management and deletion. Note that when enabled, expiration values are not respected due to Redis limitations. ```php define( 'WP_REDIS_USE_CACHE_GROUPS', true ); ``` -------------------------------- ### WP Redis New Functions (1.4.0) Source: https://github.com/pantheon-systems/wp-redis/blob/main/README.md Adds support for the `flush_runtime` and `flush_group` functions in WP Redis version 1.4.0. Users who have customized their `object-cache.php` file should incorporate these new functions. ```PHP // New functions: flush_runtime(), flush_group() ``` -------------------------------- ### Add Toolbar Item to Flush Object Cache Source: https://github.com/pantheon-systems/wp-redis/wiki/Home This snippet adds a 'Flush Object Cache' button to the WordPress admin bar. It checks if 'wp_cache_flush' function exists, adds an action to 'admin_bar_menu', and handles the cache flushing logic with nonce verification. A success notice is displayed upon flushing. ```php if ( function_exists( 'wp_cache_flush' ) ) { add_action( 'admin_bar_menu', 'o1_flush_cache_button', 100 ); } function o1_flush_cache_button( $wp_admin_bar ) { if ( ! current_user_can( 'manage_options' ) ) { return; } if ( isset( $_GET['flush-cache-button'] ) && 'flush' === $_GET['flush-cache-button'] && wp_verify_nonce( $_GET['_wpnonce'], 'flush-cache-button' ) ) { wp_cache_flush(); add_action( 'admin_notices', function () { echo '

Object Cache flushed.

'; } ); } $dashboard_url = admin_url( add_query_arg( 'flush-cache-button', 'flush', 'index.php' ) ); $args = array( 'id' => 'flush_cache_button', 'title' => 'Flush Object Cache', 'href' => wp_nonce_url( $dashboard_url, 'flush-cache-button' ), 'meta' => array( 'class' => 'flush-cache-button' ) ); $wp_admin_bar->add_node( $args ); } ``` -------------------------------- ### WP Redis New Functions Support Source: https://github.com/pantheon-systems/wp-redis/blob/main/readme.txt WP Redis 1.4.0 adds support for the `flush_runtime` and `flush_group` functions. Users who have customized the `object-cache.php` file should incorporate these additions. ```php flush_runtime ``` ```php flush_group ``` -------------------------------- ### WP Redis Failback Flag Insertion Source: https://github.com/pantheon-systems/wp-redis/blob/main/readme.txt This bug fix addresses potential SQL errors when two concurrent processes attempt to write a failback flag simultaneously. It uses `INSERT IGNORE INTO` instead of `INSERT INTO` to prevent these errors. ```sql INSERT IGNORE INTO ``` ```sql INSERT INTO ``` -------------------------------- ### WP Redis Debugging - Call Tracking Source: https://github.com/pantheon-systems/wp-redis/blob/main/README.md Tracks the number of calls to Redis and provides a breakdown of call types for debugging purposes. This helps in monitoring Redis usage and identifying potential performance bottlenecks. ```PHP // Tracking number of calls to Redis and breakdown of call types ``` -------------------------------- ### wp_cache_supports Functionality Source: https://github.com/pantheon-systems/wp-redis/blob/main/README.md Declares the `wp_cache_supports` function to define and manage supported caching features. This function is crucial for determining plugin compatibility and capabilities. ```PHP if ( ! function_exists( 'wp_cache_supports' ) ) { function wp_cache_supports( $feature ) { // Implementation details... return false; } } ``` -------------------------------- ### WP Redis Performance Boost Source: https://github.com/pantheon-systems/wp-redis/blob/main/README.md Removes redundant `exists` calls from `wp_cache_get()`, significantly reducing the number of Redis calls and improving performance. This optimization is particularly beneficial for reducing overhead in cache retrieval operations. ```PHP // Optimized wp_cache_get() to reduce Redis calls ``` -------------------------------- ### WP Redis Error Triggering Source: https://github.com/pantheon-systems/wp-redis/blob/main/readme.txt This bug fix ensures that WP Redis uses `E_USER_WARNING` with `trigger_error()` for triggering user-level warnings, providing clearer error reporting. ```php trigger_error() ``` -------------------------------- ### Broken wp_cache_supports Function Fix Source: https://github.com/pantheon-systems/wp-redis/blob/main/README.md Fixes a broken `wp_cache_supports` function, ensuring that feature detection and support reporting works correctly. ```PHP // Corrected implementation of wp_cache_supports ``` -------------------------------- ### WP Redis Failback and Flush Behavior Source: https://github.com/pantheon-systems/wp-redis/blob/main/readme.txt This documentation describes WP Redis's behavior when Redis is unavailable. It gracefully fails back to the WordPress object cache, triggers PHP errors for monitoring, attempts reconnects, and forces a flushAll on Redis when it returns. The flush behavior can be disabled. ```APIDOC WP Redis Failback and Flush Behavior: Gracefully fails back to the WordPress object cache when Redis is unavailable or intermittent. Previously, WP Redis would hard fatal. Triggers a PHP error if Redis goes away mid-request, for you to monitor in your logs. Attempts one reconnect based on specific error messages. Forces a flushAll on Redis when Redis comes back after failing. This behavior can be disabled with the `WP_REDIS_DISABLE_FAILBACK_FLUSH` constant. ``` -------------------------------- ### WP Redis Transient Cache Management Source: https://github.com/pantheon-systems/wp-redis/blob/main/readme.txt WP Redis assumes responsibility for the WordPress transient cache. For existing sites, it's recommended to delete all existing transients from the options table using the provided WP-CLI command before enabling WP Redis. ```bash $ wp transient delete-all ``` -------------------------------- ### Enable Cache Groups in WP Redis Source: https://github.com/pantheon-systems/wp-redis/blob/main/readme.txt This snippet shows how to enable opt-in support for Redis cache groups in WP Redis. When enabled, WP Redis persists cache groups in a structured manner, rather than hashing the cache key and group together. ```php define( 'WP_REDIS_USE_CACHE_GROUPS', true ); ``` -------------------------------- ### Preserving Null Values and Type Conversion Source: https://github.com/pantheon-systems/wp-redis/blob/main/README.md Bug fixes include preserving null values in the internal cache and converting numeric values to their true type when retrieving them from the cache. ```PHP // Logic to ensure null values are stored correctly // Logic to cast retrieved values to their original types (e.g., int, float) ``` -------------------------------- ### Missing Redis Message Source: https://github.com/pantheon-systems/wp-redis/blob/main/README.md Sets the `missing_redis_message` if the Redis service is not connected. This provides a user-friendly message when Redis is unavailable. ```PHP if ( ! wp_redis_is_connected() ) { $message = __( 'Redis service is not available.', 'wp-redis' ); // Set or display the message } ``` -------------------------------- ### WP Redis Cache Group Default Source: https://github.com/pantheon-systems/wp-redis/blob/main/readme.txt This bug fix ensures that WP Redis uses 'default' as the default cache group, mirroring WordPress core behavior. This makes `$wp_object_cache->add( 'foo', 'bar' )` equivalent to `wp_cache_add( 'foo', 'bar' )`. ```php $wp_object_cache->add( 'foo', 'bar' ) ``` ```php wp_cache_add( 'foo', 'bar' ) ``` -------------------------------- ### WP Redis Failback Mechanism Source: https://github.com/pantheon-systems/wp-redis/blob/main/README.md Gracefully fails back to the WordPress object cache when Redis is unavailable or intermittent. This prevents hard fatal errors and ensures continued functionality. The failback mechanism can be configured to flush all Redis data when it reconnects. ```PHP // Failback to internal object cache when Redis is unavailable // Optionally disable flushAll on reconnect: define( 'WP_REDIS_DISABLE_FAILBACK_FLUSH', true ); ``` -------------------------------- ### WP_REDIS_DEFAULT_EXPIRE_SECONDS Constant Source: https://github.com/pantheon-systems/wp-redis/blob/main/README.md Adds the `WP_REDIS_DEFAULT_EXPIRE_SECONDS` constant to set the default cache expiration time in seconds. This provides control over how long cached items remain valid. ```PHP define( 'WP_REDIS_DEFAULT_EXPIRE_SECONDS', 3600 ); ``` -------------------------------- ### WP_REDIS_IGNORE_GLOBAL_GROUPS Constant Source: https://github.com/pantheon-systems/wp-redis/blob/main/README.md Supports the `WP_REDIS_IGNORE_GLOBAL_GROUPS` constant to prevent specific groups from being added to the global caching group. This helps in managing cache behavior for different data types. ```PHP define( 'WP_REDIS_IGNORE_GLOBAL_GROUPS', true ); ``` -------------------------------- ### Disabling Persistent Object Cache for Specific Groups Source: https://github.com/pantheon-systems/wp-redis/blob/main/README.md This PHP snippet demonstrates how to prevent specific cache groups from using Redis, falling back to WordPress's default runtime object cache. This is useful for mitigating issues caused by plugins that generate an excessive number of cache keys. ```php wp_cache_add_non_persistent_groups( array( 'bad-actor' ) ); ``` -------------------------------- ### Disable Persistent Object Cache for a Group Source: https://github.com/pantheon-systems/wp-redis/blob/main/readme.txt This snippet demonstrates how to disable the persistent object cache for a specific group of cache keys. This is useful for mitigating issues caused by plugins that generate a large number of cache keys. When a group is added to the non-persistent list, operations for that group will fall back to WordPress's default runtime object cache instead of using Redis. ```php wp_cache_add_non_persistent_groups( array( 'bad-actor' ) ); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.