Module Proposal: SQLite Persistent Object Cache #625
Labels
[Focus] Object Cache
Issues related to the Object Cache focus area
Needs Discussion
Anything that needs a discussion/agreement
Performance Lab Plugin
Issue relates to work in the Performance Lab Plugin only
[Type] (Legacy) Module Proposal
A new module proposal (legacy)
Overview
About the Module
Purpose
This module persists the WordPress Object Cache using SQLite and php's SQLite3 extension. SQLite3 is enabled on many hosts' php configurations, enabling sites to use persistent object caches even when their hosts do not provision caching servers such as redis or memcached. Persistence is good for site performance: it lightens the load on the MariaDB or MySQL database server and delivers page views and requests to users faster.
Background
WordPress has a well-developed and heavily used Object Cache mechanism, accessible via the WP_Object_Cache class and via functions like wp_cache_set() and wp_cache_get(). Since version 3, WordPress has supported external persistent object caches. To do this, a drop-in module placed in
.../wp-content/object-cache.php
provides a custom cache implementation. Various plugins, notably Redis Object Cache and Memcached Object Cache, provide persistence via an external redis or memcached server.Without persistence in its object cache, every WordPress page view and API request must use the MariaDB or MySQL database server to retrieve everything it needs about the site. When a user requests a page, WordPress starts from scratch and gets everything it needs from the database server. Only then can it deliver content to the user. With a persistent object cache, WordPress has much more immediate access to much of the information it needs.
Scope
Operation
If the host php configuration offers the igbinary serializer / deserializer for serializing php variables, this module uses it. That saves a lot of cache space, especially for large and complex cached objects.
If the SQLite3 extension does not exist, or its sqlite has a version prior to 3.7, the module cannot be used, and should not activate.
When activated this module puts its drop-in into
.../wp-content/object-cache.php
.These are the drop-in's functions:
This exception handling is necessary because the drop-in uses SQLite's MEMORY journal mode to reduce file-system IO. That journal mode, though significantly faster than the ACID-safe WAL mode, is more vulnerable to corruption on program crashes.
These are the functions of the module code managing the drop-in:
Proof of concept
The proposed module is based on the code in the SQLite Object Cache plugin by @OllieJones. The source code to the current version of the plugin's
object_cache.php
drop-in is here.The text was updated successfully, but these errors were encountered: