Title: PigCache
Author: aixeiger
Published: <strong>2026 年 9 月 20 日</strong>
Last modified: 2026 年 9 月 20 日

---

搜尋外掛

![](https://s.w.org/plugins/geopattern-icon/pigcache.svg)

# PigCache

 由 [aixeiger](https://profiles.wordpress.org/aixeiger/) 開發

[下載](https://downloads.wordpress.org/plugin/pigcache.1.0.29.zip)

 * [詳細資料](https://tw.wordpress.org/plugins/pigcache/#description)
 * [使用者評論](https://tw.wordpress.org/plugins/pigcache/#reviews)
 *  [安裝方式](https://tw.wordpress.org/plugins/pigcache/#installation)
 * [開發資訊](https://tw.wordpress.org/plugins/pigcache/#developers)

 [技術支援](https://wordpress.org/support/plugin/pigcache/)

## 外掛說明

PigCache replaces WordPress’s default object cache with **Redis** (official drop-
in pattern), using PhpRedis when available or the bundled **Predis**. Configure 
the connection with `PIGCACHE_REDIS_*` constants in wp-config.php.

Features:

 * **Redis object cache** drop-in (PhpRedis or bundled Predis)
 * **SQL query cache** (optional `db.php` drop-in) with per-table invalidation, 
   so writing to one table does not discard results that never read it
 * **Full-page HTML cache** for anonymous visitors with tag-based selective invalidation
   on content changes
 * **Fragment caching** helpers backed by Redis
 * **Tag-based selective invalidation** — only affected pages are purged when a 
   post, term, or comment changes

Every feature listed above is included and fully enabled. The plugin has no license
check, no trial period and no usage limit, and it does not contact any external 
service.

The object cache drop-in is derived from [Redis Object Cache](https://github.com/rhubarbgroup/redis-cache)(
GPLv3, Till Krüss / Rhubarb Group).

### External services

This plugin does not connect to any external service. All caching, invalidation 
and metrics happen on your own server and your own Redis instance.

## 安裝方式

 1. Upload the plugin files to `wp-content/plugins/pigcache`, or install through the
    WordPress plugins screen.
 2. Activate the plugin through the **Plugins** screen.
 3. Go to **Settings  PigCache** and use **Enable object cache (copy drop-in)** when
    you are ready.
 4. Optionally install the **SQL cache** drop-in from the same screen.
 5. For the full-page HTML cache, install the `advanced-cache.php` drop-in from the
    same screen and add `define( 'WP_CACHE', true );` to your `wp-config.php`. The 
    plugin never edits `wp-config.php` for you.

Do not run another full Redis object-cache plugin at the same time; PigCache replaces
that role.

## 常見問題集

### Does this work without Redis?

No. A reachable Redis server is required for the object cache (and for HTML/fragment
features that use Redis).

### Is this the same as “Redis Object Cache”?

PigCache includes its own drop-in and must not be used together with the separate“
Redis Object Cache” plugin.

## 使用者評論

這個外掛目前沒有任何使用者評論。

## 參與者及開發者

以下人員參與了開源軟體〈PigCache〉的開發相關工作。

參與者

 *   [ aixeiger ](https://profiles.wordpress.org/aixeiger/)

[將〈PigCache〉外掛本地化為台灣繁體中文版](https://translate.wordpress.org/projects/wp-plugins/pigcache)

### 對開發相關資訊感興趣？

任何人均可[瀏覽程式碼](https://plugins.trac.wordpress.org/browser/pigcache/)、查看
[SVN 存放庫](https://plugins.svn.wordpress.org/pigcache/)，或透過 [RSS](https://plugins.trac.wordpress.org/log/pigcache/?limit=100&mode=stop_on_copy&format=rss)
訂閱[開發記錄](https://plugins.trac.wordpress.org/log/pigcache/)。

## 變更記錄

#### 1.0.25

 * Fixed: activating the plugin on a fresh site — or deactivating and reactivating
   it — could break the request outright. The constructor scheduled the plugin’s
   WP-Cron events on `plugins_loaded`, before `init`, and building the cron label
   touched a translation function that early. WordPress logs that as a notice, but
   because it is the very first byte of output in the entire request, every later`
   header()` call in that request then fails with “headers already sent” — which
   shows up as WordPress reporting unexpected output during activation, or the plugin
   being silently left deactivated. Cron registration now waits for `init`, like
   it always should have.
 * Fixed: with a cold object cache, a query could return another query’s rows. Caching
   a result or invalidating one reaches the database itself, and those internal 
   lookups overwrote the result the caller was about to read. It affected the first
   query of each kind in a request after a cache flush, a Redis restart or a fresh
   install, and the wrong rows were then cached for the full TTL. Writes were affected
   too: a lost `insert_id` could attach new rows to the wrong record.
 * Fixed: the first write to a table did not invalidate SELECTs cached before it,
   because a freshly bumped per-table epoch was indistinguishable from a missing
   one. The global epoch had the same flaw.
 * Fixed: `wp_cache_decr()` could return negative values instead of clamping at 
   zero as WordPress core does.
 * Fixed: the query-stats table was never created, because MySQL rejects a `DEFAULT`
   on a `TEXT` column.
 * Fixed: `INSERT`/`REPLACE` statements written without the optional `INTO` keyword
   were not attributed to their table.
 * The URL firewall now learns from 404s WordPress actually returned instead of 
   matching against a list of known permalinks. It no longer needs to be seeded 
   or rebuilt, and it cannot 404 real content.
 * Hardened: the URL firewall’s `wp pigcache-fw report` command now strips control/
   escape bytes before printing request data (IP, User-Agent) to the terminal, and
   the recorded IP is validated as a well-formed address instead of trusted verbatim
   from the `CF-Connecting-IP` header.
 * Hardened: request headers used by the URL firewall for instrumentation (User-
   Agent, Referer) are explicitly sanitized before being stored.
 * Fixed: the tag-index table used `DATETIME ... DEFAULT CURRENT_TIMESTAMP`, which
   MySQL only allows on `DATETIME` columns since 5.6.5 (older versions only allowed
   it on `TIMESTAMP`). On an older server the table silently failed to create, and
   worse, the very next activation queried a column on a table that didn’t exist,
   which WordPress reported as unexpected output during activation on any install
   with `WP_DEBUG` on. The two Pro-only tables with the same pattern are fixed the
   same way. None of the three columns had a default anyway — the code that writes
   to them was already setting the value itself.
 * Fixed: an inline SQL comment left inside a `CREATE TABLE` string was silently
   turned into a bogus column by `dbDelta()`, producing a broken `ALTER TABLE ADD
   COLUMN` on every activation after the first. Explanatory comments about column
   definitions now live outside the SQL string.
 * Tested against WordPress 7.1.

#### 1.0.24

 * Tag-based selective invalidation and per-table SQL invalidation are now part 
   of the plugin for everyone, with no license check of any kind.
 * The plugin no longer writes to `wp-config.php`; the `WP_CACHE` snippet is shown
   in the admin screen instead.
 * The Redis circuit breaker keeps its state in shared memory instead of a file 
   in the system temp directory.
 * Drop-ins resolve the plugin directory through `WP_PLUGIN_DIR` / `WPMU_PLUGIN_DIR`
   when those constants are available.

#### 1.0.1

 * Security: sanitize $_SERVER inputs in early-boot path and admin handlers.
 * Security: escape all outputs in object cache stats view.
 * HTML and fragment caches use tag-based selective invalidation when available,
   with global flush fallback.

#### 1.0.0

 * Initial release on WordPress.org.

## 中繼資料

 *  版本 **1.0.29**
 *  最後更新 **3 週前**
 *  啟用安裝數 **少於 10 次**
 *  WordPress 版本需求 ** 5.8 或更新版本 **
 *  已測試相容的 WordPress 版本 **7.1.3**
 *  PHP 版本需求 ** 7.4 或更新版本 **
 *  語言
 * [English (US)](https://wordpress.org/plugins/pigcache/)
 * 標籤:
 * [cache](https://tw.wordpress.org/plugins/tags/cache/)[html cache](https://tw.wordpress.org/plugins/tags/html-cache/)
   [object cache](https://tw.wordpress.org/plugins/tags/object-cache/)[performance](https://tw.wordpress.org/plugins/tags/performance/)
   [redis](https://tw.wordpress.org/plugins/tags/redis/)
 *  [進階檢視](https://tw.wordpress.org/plugins/pigcache/advanced/)

## 評分

這個項目尚無任何評論記錄。

[撰寫評分](https://wordpress.org/support/plugin/pigcache/reviews/#new-post)

[查看全部使用者評論](https://wordpress.org/support/plugin/pigcache/reviews/)

## 參與者

 *   [ aixeiger ](https://profiles.wordpress.org/aixeiger/)

## 技術支援

使用者可在技術支援論壇提出意見反應或使用問題。

 [檢視技術支援論壇](https://wordpress.org/support/plugin/pigcache/)