Giter VIP home page Giter VIP logo

object-cache-apcu's Introduction

WordPress APCu Object Cache Backend

Contributors: l3rady
Tags: APCu, object cache, backend, cache, performance, speed
Requires at least: 5.6
Tested up to: 6.5.3
Stable tag: 1.2

WordPress APCu Object Cache Backend provides a persistent memory-based backend for the WordPress object cache.

Description

WordPress APCu Object Cache Backend provides a persistent memory-based backend for the WordPress object cache.

An object cache is a place for WordPress and WordPress extensions to store the results of complex operations. On subsequent loads, this data can be fetched from the cache, which will be must faster than dynamically generating it on every page load.

Be sure to read the installation instructions, as this is not a traditional plugin, and needs to be installed in a specific location.

This object cache is a fork of Mark Jaquith's APC Object Cache Backend. There are a number of bugs in that version that have been ignored so I decided to write my own version. The object cache has been pretty much been re-written but some of the best bits from Marks version has been cherry picked over to this version.

Composer Installation

This plugin is marked as a wordpress-dropin type and can be installed automatically via composer using composer-dropin-installer.

Once the composer-dropin-installer is installed and configured in your project you can run composer require l3rady/object-cache-apcu. If set up correctly this should place the object-cache.php file into the your WordPress content dir, usually wp-content.

Manual Installation

  1. Verify that you have PHP 7.2+ and a compatible APCu version installed.
  2. Copy object-cache.php to your WordPress content directory (wp-content/ by default).
  3. Done!

Frequently Asked Questions

I share wp-config.php among multiple WordPress installs. How can I guarantee key uniqueness?

Define WP_APCU_KEY_SALT to something that is unique for each install (like an md5 of the MySQL host, database, and table prefix).

Changelog

1.2

  • Add composer file and add dropin plugin to packagist.org for easy installation via composer.
  • Add latest cache methods added to core recentlys

1.1

  • Add local array cache to reduce APCu calls for repeated requests to same keys during page load. Props to rob006
  • Add WP_APCU_LOCAL_CACHE define to disable local cache for edge cases where local cache can cause memory exhaustion issues

1.0.1

  • Make $cache_hits and $cache_misses public params for stats plugins to access

1.0

object-cache-apcu's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

object-cache-apcu's Issues

documentation about WP_APCU_KEY_SALT

Hello,
Thank you for this extension that makes wordpress greener (and faster) !

I think the docu on WP_APCU_KEY_SALT is wrong because we need to define WP_APCU_KEY_SALT not only when sharing a wp-config.php but when we share a Php instance (mutualized php). Like with php-fpm, the APC memory is shared with all pools so we have to define a unique WP_APCU_KEY_SALT for each wordpress installation.

So the documentation may be : If you have more than one Wordpress installation which share the same Php you have to define a unique WP_APCU_KEY_SALT for each.

Thanks again and cheers :-)
Cyrille37.

Install as plugin

(without activation)

Please consider adding a WP.org style readme.txt so WP-CLi could install it.

wp plugin install https://github.com/l3rady/WordPress-APCu-Object-Cache/archive/master.zip
ln -sv plugins/WordPress-APCu-Object-Cache-master/object-cache.php wp-content/

Thank you.

object-cache.php doesn’t work with WP abstraction layer

The object-cache.php doesn’t seem to work with WP functions.

wp_get_cache_type() requires a class APC_Object_Cache to exist, for example: https://github.com/wp-cli/wp-cli/blob/f701f406aa39f6aeca2af16e92712780e2675bad/php/utils-wp.php#L297-L299

In WP CLI, although wp cache supports feature returns 0, wp cache get my_key can’t find any entry in APCu, and wp cache flush fails to flush any persistent cache shown in this plugin’s info panel.

Is this plugin supposed to be compatible with the WP abstraction layer?

Slower than no cache

I have a small website, and these are the typical loading times I see logged:
no wp-content/object-cache.php: 59-63ms
Using this APCu object cache: 70-75ms

This is significantly slower than the default behaviour. I even tried making some trivial changes to improve code efficiency, such as using global $wp_object_cache, but I only managed to improve the speed to about 68-75ms.

By comparison, this Redis cache: https://wordpress.org/plugins/redis-cache/
Using that as a drop-in file (not as a plugin) gets me typical load times of 57-60ms.

APCu is supposed to be faster than Redis, so that suggests there is something inherently inefficient in this code when compared with the Redis plugin.

can not activate/deactivate plugins after object-cache.php installation

Hello Scott,

it is difficult to reproduce the issue, but sometimes i can not activate/deactivate plugins after object-cache.php installation.

i have used atec-cache-info plugin to flush the caches.

  • apcu_clear_cache();
  • $wp_object_cache->flush();
  • opcache_reset();

after that, activate/deactivate worked, sometimes. in rare cases i had to remove object-cache.php to make activate/deactivate work again.

did have any of this issue or an idea what could be the reason?

C.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.