Last active
August 14, 2025 22:59
-
-
Save afragen/f480e5b6560d191139dff7d3d0321615 to your computer and use it in GitHub Desktop.
Setup constants for running local Redis server.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Local Redis Setup | |
* Plugin URI: https://gist.github.com/afragen/f480e5b6560d191139dff7d3d0321615 | |
* Description: An mu-plugin to setup Redis server constants. | |
* Version: 0.1.0 | |
* Author: Andy Fragen | |
* License: MIT | |
* Text Domain: local-redis-setup | |
* Gist Plugin URI: https://gist.github.com/afragen/f480e5b6560d191139dff7d3d0321615 | |
* Requires PHP: 7.4 | |
* Requires WP: 6.6 | |
* | |
* Must have local Redis server installed and running. | |
* @link https://community.localwp.com/t/redis-server-for-local/51120/7?u=afragen | |
*/ | |
define('WP_REDIS_SELECTIVE_FLUSH', true); | |
define('WP_REDIS_CLIENT', 'predis'); // Use PHP client, Local does not bundle the native PhpRedis extension. | |
define('WP_REDIS_HOST', '127.0.0.1'); // Assumes redis-server is running. | |
define('WP_REDIS_PORT', 6379); // Default port is fine for us running redis-server. | |
//define('WP_REDIS_DATABASE', 3); // Either pick a unique DB per site, 0-15, or… | |
if ( ! defined('WP_REDIS_PREFIX') ) { | |
define('WP_REDIS_PREFIX', sha1( NONCE_KEY ) ); // …alternatively pick a unique prefix per site. | |
} | |
/** | |
* Add to wp-config.php | |
* define( 'WP_CACHE_KEY_SALT', sha1( NONCE_SALT ) ); | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment