Skip to content

Instantly share code, notes, and snippets.

@afragen
Last active August 14, 2025 22:59
Show Gist options
  • Save afragen/f480e5b6560d191139dff7d3d0321615 to your computer and use it in GitHub Desktop.
Save afragen/f480e5b6560d191139dff7d3d0321615 to your computer and use it in GitHub Desktop.
Setup constants for running local Redis server.
<?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