| 开发者 |
getpantheon
danielbachhuber stevector |
|---|---|
| 更新时间 | 2019年5月1日 07:56 |
| PHP版本: | 4.3 及以上 |
| WordPress版本: | 5.2 |
| 版权: | GPL-2.0 |
| 版权网址: | 版权信息 |
wp_cache_delete_group().composer install --no-dev --no-scripts after cloning to get the LCache library.wp-content/object-cache.php to require wp-content/plugins/wp-lcache/object-cache.php.wp-content/object-cache.php file should contain:
<?php
Engage LCache object caching system.
We use a 'require_once()' here because in PHP 5.5+ changes to symlinks
are not detected by the opcode cache, making it frustrating to deploy.
More info: http://codinghobo.com/opcache-and-symlink-based-deployments/
$lcache_path = dirname( realpath( FILE ) ) . '/plugins/wp-lcache/object-cache.php';
require_once( $lcache_path );
To install WP LCache in one line with WP-CLI:
wp plugin install wp-lcache --activate && wp lcache enable
If you need to install APCu, the PECL installer is the easiest way to do so.
pecl install apcupecl install channel://pecl.php.net/apcu-4.0.11apc.enable_cli='on' to your etc/php5/cli/php.ini.
If you can't easily use PHP 5.6 or greater, you should switch to a more responsible hosting provider.
Admin Notices
If any of the requirements for LCache to function are not met, you will see an admin notice indicating the issue. Here's how to resolve issues for each possible dependency:
object-cache.php symlink in place, but have not activated the plugin (which installs the LCache db table). Activate the plugin and verify the LCache tables are created.composer install --no-dev inside the wp-lcache directory, and make sure the resulting vendor directory is deployed along with the rest of wp-lcache.We've done some rudimentary testing with New Relic on Pantheon infrastructure. The results were substantial enough for us to begin using LCache in production. Watch David Strauss' DrupalCon presentation for a more thorough explanation. If you'd like to do some benchmarking yourself, we'd love to hear about your testing methodology and conclusions. Caching is more of an art than a science, and outcomes can vary. Because cost of network transactions is one of the problems solved by WP LCache, the performance gains will be more impressive if you've historically been using Redis or Memcached on a separate machine.
APCu is persistent through the life of a PHP-FPM process. However, unlike Redis, APCu doesn't save its state to disk at shutdown. When PHP-FPM is restarted, WP LCache will repopulate the L1 cache (APCu) from the L2 cache (database).
When you first enable WP LCache, you'll have a good amount of database activity as it writes all cache entries to the database. Eventually, as long as your codebase is optimized, database activity will die down and most activity will be in APCu. However, if your codebase isn't optimized, you'll see continued database load. Some common issues include:
wp_cache_flush(), which empties the entire cache and requires the L2 to be completely repopulated.wp_cache_set(), where code paths hardly ever use the cache values they set.utf8 for LCache tables [#149].utf8mb4 as a database charset [#131,#143].enable CLI command.wp lcache enable WP-CLI command to create the object-cache.php symlink.object-cache.php is missing.STRICT_ALL_TABLES on the database handler to fail and give warnings if there are issues with database inserts.LONGBLOB column type for lcache_event value column. Previously, the value column was BLOB which meant that long cache values (e.g. alloptions) could be unexpectedly truncated.wp_cache_flush() is called. Previously, LCache was called improperly, meaning none of the cache was flushed.