开发者 |
getpantheon
danielbachhuber mboynes Outlandish Josh jspellman jazzs3quence |
---|---|
更新时间 | 2023年11月28日 03:32 |
PHP版本: | 3.0.1 及以上 |
WordPress版本: | 6.4.1 |
版权: | GPLv2 or later |
版权网址: | 版权信息 |
object-cache.php
to wp-content/object-cache.php
with a symlink or by copying the file.host
parameter and change the port to null
:
$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.
);
4. 启动推进器:现在您正在使用 Redis 支持 WP 的对象缓存。
5. (Optional) To use the wp redis
WP-CLI commands, activate the WP Redis plugin. No activation is necessary if you're solely using the object cache drop-in.
6. (Optional) To use the same Redis server with multiple, discreet WordPress installs, you can use the WP_CACHE_KEY_SALT
constant to define a unique salt for each install.
7. (Optional) To use true cache groups, with the ability to delete all keys for a given group, register groups with wp_cache_add_redis_hash_groups()
, or define the WP_REDIS_USE_CACHE_GROUPS
constant to true
to enable with all groups. However, when enabled, the expiration value is not respected because expiration on group keys isn't a feature supported by Redis.
8. (Optional) On an existing site previously using WordPress' transient cache, use WP-CLI to delete all (%_transient_%
) transients from the options table: wp transient delete-all
. WP Redis assumes responsibility for the transient cache.
9. (Optional) To use Relay instead of PhpRedis as the client define the WP_REDIS_USE_RELAY
constant to true
. For support requests, please use Relay's GitHub discussions.如果您担心网站的运行速度,那么使用高性能的持久对象缓存来支持网站会产生巨大的影响。它可以减轻数据库的负担,更快地加载 WordPress 运行所需的所有数据对象。
该插件用于内部应用程序对象缓存。它与页面缓存无关。在 Pantheon 上,你不需要额外的页面缓存,但如果你是自托管,你可以使用你喜欢的页面缓存插件与 WP Redis 结合使用。
一个页面的加载需要调用 2,000 次 Redis,而对象缓存事务则需要整整 2 秒钟。如果您正在使用的插件错误地创建了大量缓存键,您可以通过禁用插件组的缓存持久性来缓解问题:
wp_cache_add_non_persistent_groups( array( 'bad-actor' ) );
This declaration means use of wp_cache_set( 'foo', 'bar', 'bad-actor' );
and wp_cache_get( 'foo', 'bad-actor' );
will not use Redis, and instead fall back to WordPress' default runtime object cache.
There's a known issue with WordPress alloptions
cache design. Specifically, a race condition between two requests can cause the object cache to have stale values. If you think you might be impacted by this, review this GitHub issue for links to more context, including a workaround.
Please report security bugs found in the source code of the WP Redis plugin through the Patchstack Vulnerability Disclosure Program. The Patchstack team will assist you with verification, CVE assignment, and notify the developers of this plugin.
get_multiple
function [#448] (props @souptik)array_replace_recursive
and other issues [434] (props @timnolte)esc_html
in _exception_handler()
[421]wp_cache_flush_runtime
should only clear the local cache [413]flush_runtime
and flush_group
functions [#405]pantheon-wp-coding-standards
[#400]missing_redis_message
if Redis service is not connected [#391].wp_cache_supports
function [#382].wp_cache_supports
function and support features. [#378]develop
branch for PRs. [#376]WP_REDIS_USE_RELAY
constant [#344].WP_REDIS_IGNORE_GLOBAL_GROUPS
check [#333].WP_REDIS_IGNORE_GLOBAL_GROUPS
constant to prevent groups from being added to global caching group [#331].$_SERVER
in wp_redis_get_info()
[#316].wp_cache_get_multiple()
and internal cache is already primed [#292].wp_cache_get_multiple()
for WordPress 5.5 [#287].wp redis cli
by using proc_open()
directly, instead of WP_CLI::launch()
[#268].WP_REDIS_DEFAULT_EXPIRE_SECONDS
constant to set default cache expire value [#264].flushdb
instead of flushAll
to avoid flushing the entire Redis instance [#259].wp_cache_init()
for drop-ins like LudicrousDB [#231].redis-cli
.wp redis debug
to display cache hit/miss ratio for any URL; wp redis info
to display high-level Redis statistics; wp redis enable
to create the object-cache.php
symlink.$redis_server['database']
.wp_cache_add_redis_hash_groups()
, which permits registering specific groups to use Redis hashes, and is more precise than our existing WP_REDIS_USE_CACHE_GROUPS
constant.exists
call from wp_cache_get()
, which easily halves the number of Redis calls.add_action()
and $wpdb
in a safer manner for compatibility with Batcache, which loads the object cache before aforementioned APIs are available.del
instead of delete
.exists
call against Redis.wp redis-cli
, a WP-CLI command to launch redis-cli with WordPress' Redis credentials.$wp_object_cache->add( 'foo', 'bar' )
=== wp_cache_add( 'foo', 'bar' )
.define( 'WP_REDIS_USE_CACHE_GROUPS', true );
. When enabled, WP Redis persists cache groups in a structured manner, instead of hashing the cache key and group together.$redis_server['host']
by ensuring the supplied $port
is null.INSERT IGNORE INTO
instead of INSERT INTO
to prevent SQL errors when two concurrent processes attempt to write failback flag at the same time.E_USER_WARNING
with trigger_error()
.$wpdb->options
isn't yet initialized on multisite.WP_REDIS_DISABLE_FAILBACK_FLUSH
constant.