Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A persistent object cache backend for WordPress powered by Redis. Supports Predis, PhpRedis, Relay, replication, sentinels, clustering and WP-CLI.

License

NotificationsYou must be signed in to change notification settings

rhubarbgroup/redis-cache

Repository files navigation

A persistent object cache backend powered by Redis®¹. SupportsPredis,PhpRedis (PECL),Relay, replication, sentinels, clustering andWP-CLI.

Redis Object Cache screenshots

Object Cache Pro

Abusiness class Redis®¹ object cache backend. Truly reliable, highly optimized, fully customizable and with a dedicated engineer when you most need it.

  • Rewritten for raw performance
  • 100% WordPress API compliant
  • Faster serialization and compression
  • Easy debugging & logging
  • Cache prefetching and advanced analytics
  • Fully unit tested (100% code coverage)
  • Optimized for WooCommerce, Jetpack & Yoast SEO
  • And much more...

Installation

To get started, please see theinstallation instructions.

FAQ & Troubleshooting

Answers to common questions and troubleshooting of common errors can be found in theFAQ.

Configuration

The Redis Object Cache plugin comes with vast set of configuration options. If you're unsure how to use them read theinstallation instructions.

Configuration constantDefaultDescription
WP_REDIS_HOST127.0.0.1The hostname of the Redis server
WP_REDIS_PORT6379The port of the Redis server
WP_REDIS_PATHThe path to the unix socket of the Redis server
WP_REDIS_SCHEMEtcpThe scheme used to connect:tcp orunix
WP_REDIS_DATABASE0The database used by the cache:0-15
WP_REDIS_PREFIXThe prefix used for all cache keys to avoid data collisions (replacesWP_CACHE_KEY_SALT), should be human readable and not a "salt"
WP_REDIS_PASSWORDThe password of the Redis server, supports Redis ACLs arrays:['user', 'password']
WP_REDIS_MAXTTL0The maximum time-to-live of cache keys
WP_REDIS_CLIENTThe client used to communicate with Redis (defaults tophpredis when installed, otherwisepredis), supportsphpredis,predis,relay
WP_REDIS_TIMEOUT1The connection timeout in seconds
WP_REDIS_READ_TIMEOUT1The timeout in seconds when reading/writing
WP_REDIS_IGNORED_GROUPS[]Groups that should not be cached between requests in Redis
Advanced configuration options
Configuration constantDefaultDescription
WP_CACHE_KEY_SALTDeprecated. Replaced byWP_REDIS_PREFIX
WP_REDIS_FLUSH_TIMEOUT5Experimental. The timeout in seconds when flushing
WP_REDIS_RETRY_INTERVALThe number of milliseconds between retries (PhpRedis only)
WP_REDIS_GLOBAL_GROUPS[]Additional groups that are considered global on multisite networks
WP_REDIS_METRICS_MAX_TIME3600The maximum number of seconds metrics should be stored
WP_REDIS_IGBINARYfalseWhether to use the igbinary PHP extension for serialization
WP_REDIS_DISABLEDfalseEmergency switch to bypass the object cache without deleting the drop-in
WP_REDIS_DISABLE_ADMINBARfalseDisables admin bar display
WP_REDIS_DISABLE_METRICSfalseDisables metrics collection and display
WP_REDIS_DISABLE_DROPIN_CHECKfalseDisables the extended drop-in write test
WP_REDIS_DISABLE_DROPIN_AUTOUPDATEfalseDisables the drop-in auto-update
WP_REDIS_DISABLE_GROUP_FLUSHfalseDisables group flushing with Lua script and usesflushdb call instead
WP_REDIS_DISABLE_BANNERSfalseDisables promotional banners and notices
WP_REDIS_DISABLE_COMMENTfalseDisables HTML source comment
WP_REDIS_SSL_CONTEXT[]TLS connection options fortls orrediss scheme
WP_REDIS_MANAGER_CAPABILITYThe capability a user must have to manage the plugin
Unsupported configuration options

Options that exist, butshould not,may break without notice in future releases andwon't receive any support whatsoever from our team:

Configuration constantDefaultDescription
WP_REDIS_GRACEFULfalsePrevents exceptions from being thrown, but will cause data corruption
WP_REDIS_SELECTIVE_FLUSHfalseUses terribly slow Lua script for flushing
WP_REDIS_UNFLUSHABLE_GROUPS[]Uses terribly slow Lua script to prevent groups from being flushed

Connections

Connecting over Unix socket
define('WP_REDIS_SCHEME','unix' );define('WP_REDIS_PATH','/var/run/redis.sock' );
Connecting over TCP+TLS
define('WP_REDIS_SCHEME','tls' );define('WP_REDIS_HOST','master.ncit.ameaqx.use1.cache.amazonaws.com' );define('WP_REDIS_PORT',6379 );

Additional TLS/SSL stream connection options for connections can be defined usingWP_REDIS_SSL_CONTEXT:

define('WP_REDIS_SSL_CONTEXT', ['verify_peer' =>false,'verify_peer_name' =>false,]);
Connecting using ACL authentication
define('WP_REDIS_PASSWORD', ['username','password' ] );

Scaling

Redis Object Cache offers various replication, sharding, cluster and sentinel setups to users with advanced technical knowledge of Redis and PHP, that have consulted thePredis,PhpRedis orRelay documentation.

Relay

Relay is a next-generation cache that keeps a partial replica of Redis' dataset in PHP's memory for ridiculously fast lookups, especially when Redis Server is not on the same machine as WordPress.

define('WP_REDIS_CLIENT','relay' );define('WP_REDIS_HOST','127.0.0.1' );define('WP_REDIS_PORT',6379 );// when using Relay, each WordPress installation// MUST a dedicated Redis database and unique prefixdefine('WP_REDIS_DATABASE',0 );define('WP_REDIS_PREFIX','db3:' );// consume less memorydefine('WP_REDIS_IGBINARY',true );
Replication

https://redis.io/docs/management/replication/

define('WP_REDIS_CLIENT','predis' );define('WP_REDIS_SERVERS', ['tcp://127.0.0.1:6379?database=5&role=master','tcp://127.0.0.2:6379?database=5&alias=replica-01',] );
Sharding

This is a PhpRedis specific feature usingRedisArray.

define('WP_REDIS_CLIENT','phpredis' );define('WP_REDIS_SHARDS', ['tcp://127.0.0.1:6379?database=10&alias=shard-01','tcp://127.0.0.2:6379?database=10&alias=shard-02','tcp://127.0.0.3:6379?database=10&alias=shard-03',] );
Redis Sentinel

https://redis.io/docs/management/sentinel/

define('WP_REDIS_CLIENT','predis' );define('WP_REDIS_SENTINEL','my-sentinel' );define('WP_REDIS_SERVERS', ['tcp://127.0.0.1:5380','tcp://127.0.0.2:5381','tcp://127.0.0.3:5382',] );
Redis Cluster

https://redis.io/docs/management/scaling/

define('WP_REDIS_CLIENT','phpredis' );define('WP_REDIS_CLUSTER', ['tcp://127.0.0.1:6379?alias=node-01','tcp://127.0.0.2:6379?alias=node-02','tcp://127.0.0.3:6379?alias=node-03',] );

WP CLI commands

Redis Object Cache has various WP CLI commands, for more information runwp help redis.

CommandDescription
wp redis statusShows the object cache status and diagnostics
wp redis enableEnables the object cache
wp redis disableDisables the object cache
wp redis update-dropinUpdates the object cache drop-in

Actions & Filters

Redis Object Cache has various hooks and the commonly used ones are listed below.

Filter / ActionDescription
redis_cache_expirationFilters the cache expiration for individual keys
redis_cache_validate_dropinFilters whether the drop-in is valid
redis_cache_add_non_persistent_groupsFilters the groups to be marked as non persistent
redis_cache_manager_capabilityFilters the capability a user needs to manage the plugin

Footnotes

¹ Redis is a registered trademark of Redis Ltd. Any rights therein are reserved to Redis Ltd. Any use by Redis Object Cache is for referential purposes only and does not indicate any sponsorship, endorsement or affiliation between Redis and Redis Object Cache.


[8]ページ先頭

©2009-2025 Movatter.jp