前言介紹
- 這款 WordPress 外掛「{eac}ObjectCache – a persistent object cache using a SQLite database to cache WordPress objects.」是 2024-04-02 上架。
- 目前尚無安裝啟用數,是個很新的外掛。如有要安裝使用,建議多測試確保功能沒問題!
- 上一次更新是 2025-04-22,距離現在已有 10 天。
- 外掛最低要求 WordPress 5.8 以上版本才可以安裝。
- 外掛要求網站主機運作至少需要 PHP 版本 7.4 以上。
- 有 1 人給過評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
外掛標籤
SQLite | WP Cache | performance | object cache | persistent object cache |
內容簡介
{eac}Doojigger Object Cache ({eac}ObjectCache) 是一個輕量且非常高效的持久性對象快取,使用快速的 SQLite 資料庫來對 WordPress 的對象進行快取。
對象快取外掛介紹
問題與答案:
什麼是 WordPress 對象快取?
WordPress 對象快取用於節省對資料庫的訪問次數。預設情況下,對象快取是非持久性的,這表示快取中的資料僅在記憶體中存儲,並僅在請求期間保持。
{eac}ObjectCache 有哪些特點?
{eac}ObjectCache 取代了 WordPress 的預設對象快取,不僅將資料存儲在記憶體中,還將資料持久化存儲在 SQLite 資料庫中,增加了快取命中率,減少了昂貴的計算、複雜的 MySQL 資料庫查詢和遠程 API 請求的需求。同時,它支援 L1 (內存) 和 L2 (SQLite) 快取,以及延遲交易或通過快取進行寫回。
如何調整 SQLite 資料庫的位置?
您可以透過在 wp-config.php 檔案中添加定義的常數來調整 SQLite 資料庫的位置。默認情況下,建議使用默認設置,但基於流量量、具體需求或特定情況,可能需要調整單獨的設置。
原文外掛簡介
The {eac}Doojigger Object Cache ({eac}ObjectCache) is a light-weight and very efficient drop-in persistent object cache that uses a fast SQLite database to cache WordPress objects.
See The WordPress Object Cache
The WordPress Object Cache is used to save on trips to the database. The Object Cache stores all of the cache data to memory and makes the cache contents available by using a key, which is used to name and later retrieve the cache contents.
By default, the object cache is non-persistent. This means that data stored in the cache resides in memory only and only for the duration of the request. Cached data will not be stored persistently across page loads unless you install a persistent caching plugin.
Here, an object is any piece of data – a number, text, a set of database records, an API response, etc. – that can be referenced by a name or key. Objects are categorized by a group name. Groups help identify what an object is and how it is used.
{eac}ObjectCache replaces the default WordPress object cache to not only store data in memory but to also store data persistently, across requests, in a SQLite database, increasing the likelihood of cache hits and decreasing the need for costly computations, complex MySQL database queries, and remote API requests.
SQLite is a fast, small, single-file relational database engine. By using SQLite to store objects, {eac}ObjectCache is able to manage a relatively large amount of data (groups, keys, and values) in a very efficient and fast data-store.
Features
Lightweight, efficient, and fast!
L1 (memory) and L2 (SQLite) caching.
Supports Write-Back (delayed transactions) or Write-Through caching.
Cache by object group name.
Preserves uniqueness of keys.
Manage keys by group name.
Pre-fetch object groups from L2 to L1 cache.
Caches and pre-fetches L2 misses (known to not exist in L2 cache).
Prevents repeated, unnecessary L2 cache reads across requests.
Multisite / Network support:
Cache/flush/switch by blog id.
Caching statistics:
Cache hits typically well above 90%.
Overall and L1/L2 hits, misses, & ratio.
L1 hits by object groups.
L2 group keys stored.
L2 select/update/delete/commit counts.
Supports an enhanced superset of WP_Object_Cache functions.
Easily enabled or disabled from {eac}Doojigger administrator page.
Imports existing transients when enabled.
Exports cached transients when disabled.
Automatically cleans and optimizes SQLite database.
Optionally schedule periodic L2 cache rebuild.
Uses the PHP Data Objects (PDO) extension included with PHP.
Settings
Several cache settings can be modified by adding defined constants to the wp-config.php file. The default settings are recommended and optimal in most cases but individual settings may need to be adjusted based on traffic volume, specific requirements, or unique circumstances. Most of these settings can be adjusted in the {eac}Doojigger administrator screen.
To set the location of the SQLite database (default: ../wp-content/cache):
define( 'EAC_OBJECT_CACHE_DIR', '/full/path/to/folder' );
This folder can be outside of the web-accessable folders of your site – i.e. above the document root (htdocs, www, etc.) – provided that PHP can access (read/write) the folder (see the PHP open_basedir directive).
This folder should not be on a network share or other remote media. We’re caching data for quick access, the cache folder should be on fast, local media.
To set the name of the SQLite database (default: ‘.eac_object_cache.sqlite’):
define( 'EAC_OBJECT_CACHE_FILE', 'filename.sqlite' );
In addition to the database file, SQLite may also create temporary files using the same file name with a ‘-shm’ and ‘-wal’ suffix.
To set SQLite journal mode (default: ‘WAL’):
define( 'EAC_OBJECT_CACHE_JOURNAL_MODE', journal_mode )
journal_mode can be one of ‘DELETE’, ‘TRUNCATE’, ‘PERSIST’, ‘MEMORY’, ‘WAL’, or ‘OFF’.
See SQLite journal mode
To set SQLite Mapped Memory I/O (default: 0):
define( 'EAC_OBJECT_CACHE_MMAP_SIZE', int );
Sets the maximum number of bytes that are set aside for memory-mapped I/O.
See SQLite memory-mapped I/O
To set SQLite Page Size (default: 4096):
define( 'EAC_OBJECT_CACHE_PAGE_SIZE', int );
Sets the SQLite page size for the database.
See SQLite page size
To set SQLite Cache Size (default: -2000 [2,048,000]):
define( 'EAC_OBJECT_CACHE_CACHE_SIZE', int );
Sets the maximum number of database disk pages that SQLite will hold in memory or the maximum amount of memory to use for page caching.
See SQLite cache size
To set SQLite timeout (default: 3):
define( 'EAC_OBJECT_CACHE_TIMEOUT', int );
Sets the number of seconds before a SQLite transaction may timeout in error.
To set SQLite retries (default: 3):
define( 'EAC_OBJECT_CACHE_MAX_RETRIES', int );
Sets the maximum number of retries to attempt on critical actions.
To set delayed writes (default: 32):
define( 'EAC_OBJECT_CACHE_DELAYED_WRITES', true|false|int );
{eac}ObjectCache caches all objects in memory and writes new or updated objects to the L2 (SQLite) cache. delayed writes simply holds objects in memory until the number of objects reaches a specified threshold, then writes them, in a single transaction, to the L2 cache (a.k.a. write-back caching). Setting delayed writes to false turns this functionality off (a.k.a. write-through caching). Setting to true writes all records only at the end of the script process/page request. Setting this to a number sets the object pending threshold to that number of objects.
To set the default expiration time (in seconds) (default: 0 [never]):
define( 'EAC_OBJECT_CACHE_DEFAULT_EXPIRE', -1|0|int );
When using the default WordPress object cache, object expiration isn’t very important because the entire cache expires at the end of the script process/page request. With a persistent cache, this isn’t the case. When an object is cached, the developer has the option of specifying an expiration time for that object. Since we don’t know the intent of the developer when not specifying an expiration time, cache persistence may sometimes cause issues. Setting default expiration may alleviate problems and/or possibly improve performance by limiting cache data. When set to -1, objects with no expiration are not saved in the L2 cache.
* Transients with no expiration overide this setting and are allowed (as that is the normal WordPress functionality).
* More often than not, unexpired objects are updated when the source data has changed and do not present any issues.
To enable or disable pre-fetching of cache misses (default: true [enabled]):
define( 'EAC_OBJECT_CACHE_PREFETCH_MISSES', true | false );
Pre-fetching cache misses (keys that are not in the L2 persistent cache) prevents repeated, unnecessary reads of the L2 cache.
To set maintenance probability (default: 1000):
define( 'EAC_OBJECT_CACHE_PROBABILITY', int );
Sets the probability of running maintenance (garbage collection) tasks – approximately 1 in n requests, n>=10.
Object groups that are global (not site-specific) in a multi-site/network environment:
define( 'EAC_OBJECT_CACHE_GLOBAL_GROUPS', [ 'groupA', 'groupB', ... ] );
Global Object groups are not tagged with or separated by the site/blog id.
* WordPress already defines several global groups that do not need to be duplicated here, rather the groups entered here are added to those defined by WordPress.
Object groups that should not be stored in the persistent cache:
define( 'EAC_OBJECT_CACHE_NON_PERSISTENT_GROUPS', [ 'groupA', 'groupB', ... ] );
Non-persistent groups are object groups that do not persist across page loads. This may be another method to alleviate issues caused by cache persistence or to improve performance by limiting cache data.
* WordPress already defines several non-persistent groups that do not need to be duplicated here, rather the groups entered here are added to those defined by WordPress.
Object groups that are allowed permanence:
define( 'EAC_OBJECT_CACHE_PERMANENT_GROUPS', [ 'groupA', 'groupB', ... ] );
When setting a default expiration (EAC_OBJECT_CACHE_DEFAULT_EXPIRE) for objects without an expiration, these groups are excluded from using the default, allowing them to be permanent (with no expiration). Transients and site-transients are automatically included.
To pre-fetch specific object groups from the L2 cache at startup:
define( 'EAC_OBJECT_CACHE_PREFETCH_GROUPS', [ 'groupA', 'groupB', ... ] );
Pre-fetching a group of records may be much faster than loading each key individually, but may load keys that are not needed, using memory unnecessarily.
To prevent outside actors (scripts, plugins, etc.), including WordPress, from flushing caches.
define( 'EAC_OBJECT_CACHE_DISABLE_FLUSH', true );
define( 'EAC_OBJECT_CACHE_DISABLE_FULL_FLUSH', true );
define( 'EAC_OBJECT_CACHE_DISABLE_GROUP_FLUSH', true );
define( 'EAC_OBJECT_CACHE_DISABLE_BLOG_FLUSH', true );
define( 'EAC_OBJECT_CACHE_DISABLE_RUNTIME_FLUSH', true );
Utility methods
Outputs an html table of current stats. Use $wp_object_cache->statsCSS to style.
$wp_object_cache->htmlStats();
Outputs an html table of current stats similar to that generated by the default WordPress object cache.
$wp_object_cache->stats();
Returns an array of current stats.
$cacheStats = $wp_object_cache->getStats();
Returns an array of stats from the last sample saved (or current).
$cacheStats = $wp_object_cache->getLastSample();
Optional runtime settings
Delay writing to database until shutdown or n pending records (see delayed writes).
$wp_object_cache->delayed_writes = true | false | n;
Samples (every n requests) & outputs an admin notice with htmlStats().
$wp_object_cache->display_stats = n;
Change the default expiration time for objects with no expiration.
$wp_object_cache->default_expire = n;
Outputs an administrator notice on error.
$wp_object_cache->display_errors = true;
Log errors to {eac}Doojigger log.
$wp_object_cache->log_errors = true;
WP-Cache
Implemented Standard and Non-Standard WP-Cache API Functions:
wp_cache_init()
wp_cache_add( $key, $data, $group = ”, $expire = 0 )
wp_cache_add_multiple( array $data, $group = ”, $expire = 0 )
wp_cache_replace( $key, $data, $group = ”, $expire = 0 )
wp_cache_replace_multiple( array $data, $group = ”, $expire = 0 )
wp_cache_set( $key, $data, $group = ”, $expire = 0 )
wp_cache_set_multiple( array $data, $group = ”, $expire = 0 )
wp_cache_get( $key, $group = ”, $force = false, &$found = null )
wp_cache_get_multiple( $keys, $group = ”, $force = false )
wp_cache_get_group( $group )
wp_cache_delete( $key, $group = ” )
wp_cache_delete_multiple( array $keys, $group = ” )
wp_cache_delete_group( $group )
wp_cache_incr( $key, $offset = 1, $group = ” )
wp_cache_decr( $key, $offset = 1, $group = ” )
wp_cache_flush()
wp_cache_flush_runtime()
wp_cache_flush_group( $group )
wp_cache_flush_blog( $blog_id = null )
wp_cache_supports( $feature )
wp_cache_close()
wp_cache_add_global_groups( $groups )
wp_cache_add_non_persistent_groups( $groups )
wp_cache_add_permanent_groups( $groups )
wp_cache_add_prefetch_groups( $groups )
wp_cache_switch_to_blog( $blog_id )
Examples
`php
/*
* add custom groups to global (not blog-specific)
*/
wp_cache_add_global_groups( [ 'ridiculous', 'absurd' ] );
/*
* calculate the sum of all digits in Pi multiplied by each known prime number...
* only do this once a year (or when cache is cleared) 'cause it may take a while.
*/
if ( ! $result = wp_cache_get('calculation_result','ridiculous') ) {
$result = do_calculation();
wp_cache_set( 'calculation_result', $result, 'ridiculous', YEAR_IN_SECONDS );
}
/*
* get all objects in the 'ridiculous' group.
*/
if (wp_cache_supports( 'get_group' )) {
$ridiculous = wp_cache_get_group( 'ridiculous' );
}
/*
* erase the 'ridiculous' group
*/
wp_cache_flush_group( 'ridiculous' );
/*
* erase the cache for this blog only (multisite)
*/
if (wp_cache_supports( 'flush_blog' )) {
wp_cache_flush_blog();
}
`= Additional Information =
{eac}ObjectCache is an extension plugin to and is fully functional with installation and registration of {eac}Doojigger.
However, the core object-cache.php file may be installed without {eac}Doojigger – referred to as ‘detached’ mode.
In detached mode, the plugin will attempt to copy the object-cache.php file to the /wp-content folder on activation, or you may manually copy the object-cache.php file from the plugin /src folder to the /wp-content folder to activate. Options can then be set using the documented PHP constants in the wp-config.php file.
Copyright
Copyright © 2025, EarthAsylum Consulting, distributed under the terms of the GNU GPL.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should receive a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「{eac}ObjectCache – a persistent object cache using a SQLite database to cache WordPress objects.」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
1.0.3 | 1.0.4 | 1.1.0 | 1.2.0 | 1.2.1 | 1.2.2 | 1.3.0 | 1.3.1 | trunk |
延伸相關外掛(你可能也想知道)
LiteSpeed Cache 》LiteSpeed Cache for WordPress(LSCWP)是一種全方位的網站加速外掛,包括獨家的伺服器層快取和一系列的優化功能。, LSCWP 支援 WordPress Multisite 及大多...。
Jetpack – WP Security, Backup, Speed, & Growth 》search engines, and grow your traffic with Jetpack. It’s the ultimate toolkit for WordPress professionals and beginners alike., , Customize and des...。
Image Optimizer – Optimize Images and Convert to WebP or AVIF 》外掛總結:, , - Image Optimizer 是一個易於使用的 WordPress 外掛,透過壓縮和調整大小的技術來減少圖像大小,同時保留最高的圖像品質。, - Image Optimize...。
WP Super Cache 》本外掛可以從您的動態 WordPress 部落格生成靜態 HTML 檔案。在產生 HTML 檔案後,您的網頁伺服器會傳送該檔案,而不是處理比較沉重、耗費更多資源的 WordPre...。
WP Fastest Cache 》han PNG or JPEG, which means faster downloads and less data consumption for your visitors, Database Cleanup – Detect and delete unnecessary d...。
ManageWP Worker 》, Want to clone or migrate your WordPress website to a new host or domain? No problem! With ManageWP, you can easily clone or migrate your website ...。
W3 Total Cache 》W3 Total Cache (W3TC) 透過整合內容傳遞網絡 (CDN) 和最新最佳實踐等功能,提高網站性能、減少加載時間,增進 SEO、核心 Web 主要指標和整體用戶體驗。W3TC ...。
Speed Optimizer – The All-In-One Performance-Boosting Plugin 》SiteGround Optimizer 插件是由 SiteGround 開發的,可以大幅提高任何托管環境下的 WordPress 網站性能。, 最初設計用於 SiteGround 的服務器,現在已經有近 ...。
Autoptimize 》Autoptimize 能夠輕鬆優化您的網站。它可以整合、縮小和快取腳本和樣式表,在默認情況下向頁面 head 中注入 CSS,但也可以內嵌關鍵 CSS 並延遲整合的完整 CSS...。
AMP 》「Page Experience」(PX)是一組排名訊號,包括「核心網頁素質」(Core Web Vitals,CWV),用來測量使用者與網頁互動的使用體驗。AMP 是一個強大的工具,能...。
WebP Express 》ch means less bandwidth usage and faster page load times., Easy to use - with little effort, WordPress site admins can have their site serving auto...。
Breeze – WordPress Cache Plugin 》Breeze是由Cloudways團隊開發的一款免費、簡單(卻功能強大)且使用者友好的WordPress快取外掛。它提供不同層級的WordPress效能優化選項,在WordPress、搭配W...。
Jetpack Boost – Website Speed, Performance and Critical CSS 》使用 Jetpack Boost 優化網頁性能加速你的 WordPress 網站。輕鬆啟用一鍵優化,提升核心 Web 重要指標。, 你是否知道,更快的網站可以:, , 在 Google 搜尋排...。
Custom Fonts – Host Your Fonts Locally 》此外掛能協助您輕鬆地在 WordPress 網站中嵌入自定義字型檔案 (woff2、woff、ttf、svg、eot、otf)。, 目前能與以下主題和外掛一起使用:, , Astra 主題, Beav...。
Redis Object Cache 》一個由 Redis 提供支援的持久化物件快取後端。支援 Predis、PhpRedis (PECL)、Relay、複寫、哨兵、叢集化和 WP-CLI。, 若要調整連線參數、前綴的快取鍵或設定...。