该插件尚未通过WordPress的最新3个主要版本进行测试。 当与较新版本的WordPress一起使用时,可能不再受到维护或支持,并且可能会存在兼容性问题。

Memcached 对象缓存

描述

Memcached 对象缓存为 WordPress 对象缓存提供了一个持久的后台。需要一个 memcached 服务器和 PECL memcache 扩展。

安装

  1. 在至少一台服务器上安装 memcached 。注意连接信息。默认值为127.0.0.1:11211

  2. 安装 PECL memcache 扩展

  3. 将 object-cache.php 复制到 wp-content

  4. wp-config.php 中添加 WP_CACHE_KEY_SALT 常量:

    php
    define( 'WP_CACHE_KEY_SALT', '...长随机字符串...' );

当多个 WordPress 安装使用同一 Memcached 服务器时,这有助于防止缓存污染。每个 WordPress 安装的值必须是唯一的。

常见问题

如何手动指定 memcached 服务器?

在上面的 wp-config.php 中添加类似以下内容 /* 就这样,停止编辑!祝您写博愉快。*/

$memcached_servers = array(
    'default' => array(
        '10.10.10.20:11211',
        '10.10.10.30:11211'
    )
);

顶层数组键是缓存组,其中 "默认 "对应于任何未明确定义的缓存组。这样就可以指定只处理某些缓存组的 memcached 服务器。最常见的用法是只指定 "默认"。

可能的高速缓存组有

{$taxonomy}_relationships
{$meta_type}_meta
{$taxonomy}_relationships
blog-details
blog-id-cache
blog-lookup
bookmark
calendar
category
comment
counts
general
global-posts
options
plugins
post_ancestors
post_meta
posts
rss
site-lookup
site-options
site-transient
terms
themes
timeinfo
transient
user_meta
useremail
userlogins
usermeta
users
userslugs
widget

评价

2023 年 10 月 21 日
Install is not like other plugins -- and in fact if you do upload it to plugins and then activate it, it'll bring your site down in many cases. You can upload it (but don't activate!) and then use the server side to move the plugin file manually into wp-content (and then delete the uploaded plugin folder and readme.txt). But that's not enough to make the whole thing work! You also need memcached running on your server and properly configured, and the pecl memcache extension compiled on the server side in your php configuration, too. Make sure to use a unique salt as well. Once it's all there, the speed improvement is significant! Happy to try and help those that respond to this thread if you need -- or at least try to get you pointed in the right direction. Thanks for the plugin, devs! Appreciate as you update and keep current as well!
2023 年 7 月 8 日
@terrykernan I moved like you said but then i get ciritcal error and can enter the Admin section of wordpress, when i remove it from WP-Content everything works again. I installed the plugin only because i have Redis on my host
2023 年 5 月 17 日 1 回复
Tip for others here, if you are getting this error: "Cannot redeclare wp_cache_add" It probably means you have the object-cache.php file in the wrong directory, it should not be in the plugins/memcached/ folder, it should be moved to the wp-content folder!
2023 年 4 月 5 日 1 回复
Fatal error: Cannot redeclare wp_cache_add() (previously declared in /htdocs/wp-includes/cache.php:41) in /htdocs/wp-content/plugins/memcached/object-cache.php on line 19
2023 年 2 月 16 日
It works well even with WPRocket Cache plugin. If you get fatal errors don't forget to install PECL memcache module to PHP.
阅读所有30条评价

贡献者及开发者

「Memcached 对象缓存」插件已被翻译至 4 种本地化语言。 感谢所有译者为本插件所做的贡献。

将“Memcached 对象缓存”翻译成您的语言。

对开发感兴趣吗?

您可以浏览代码,查看SVN仓库,或通过RSS订阅开发日志

更新日志

4.0.0

  • 添加抢占式过滤器 pre_wp_cache_get
  • 添加 flush_number 复制功能,以防止因 flush_number 驱逐、服务器轮换等原因造成意外刷新。

3.2.2

  • 移除过滤器,并根据是否存在 key_salt 来剥离按键

3.2.1

  • 修复允许 slow-ops 条目具有相同按键的错误,因此切换不起作用

3.2.0

  • 更好的 stats()。现在可显示缓存组/单个调用的有效载荷大小和时间。
  • 现在需要使用 PHP 5.6.20
  • 修复 get_multi 以显示每个组的呼叫
  • 添加了过滤器 (memcached_strip_keys),以绕过 memcached 的键值剥离操作
  • 用于 slow-ops ( > 5ms ) 的特殊组,带回溯跟踪

3.1.0

  • 添加wp_cache_get_multi
  • 添加对 $found 参数的支持
  • 将 $max_expiration 变量设置为 30 天
  • 代码样式更改
  • 未知统计组的不同着色
  • 在故障回调中存储主机/端口
  • 默认统计计数

3.0.2

  • 更好地输出 HTML

3.0.1

  • 修正 switch_too_blog() 中的密钥生成错误

3.0.0

  • 通过旋转键清除网站缓存
  • 刷新主网站时刷新全局缓存

2.0.6

  • 使用 wp_cache_flush() 清空本地缓存

2.0.5

  • 修复 switch_too_blog 中丢失的全局

2.0.4

  • 删除过时的构造函数

2.0.3

  • 支持 unix 套接字

2.0.2

  • 通过克隆对象中断引用
  • 使用 incr 和 decr 时保持本地缓存与 memcached 同步
  • 处理未定义 is_multisite() 的有限环境
  • 修复设置并得到 0
  • 现在需要使用 PHP 5.2.4
  • 如果有的话,使用 WP_CACHE_KEY_SALT 常量来保证密钥的唯一性