mycache is a native PHP extension written in C++ that replaces network-based object caching
(Redis/Memcached) with a local, ultra-low-latency cache in RAM. It integrates with WordPress as a
drop-in object-cache.php and is designed for WooCommerce-heavy workloads.
WordPress and WooCommerce read and write objects through the standard
wp_cache_get(), wp_cache_set() APIs.
mycache keeps full compatibility via a drop-in.
The drop-in stores values in-request (memory) and, when available, persists them using the native
extension functions (mycache_get, mycache_set, etc.).
Persistent objects are stored as small files in a RAM-backed directory
(typically /dev/shm), avoiding TCP, network jitter, and external services.
mycache persists each cached entry as a compact binary file in a directory that lives in RAM
(for Linux typically /dev/shm). This keeps reads and writes local and fast.
/dev/shm/mycache (configurable)chmod_mode, SGID on dirs)Keys are hashed (FNV-1a 64-bit) and mapped into a fixed number of subdirectories (fanout). This avoids performance issues caused by huge single directories.
256 (configurable)base/subdir/mc-<hash>.binWrites are performed atomically using a temporary file and rename. Reads use shared locks, updates use exclusive locks. This keeps cache consistent even with high concurrency.
mkstemp → write → fdatasync → rename → fsync(dir)flock(LOCK_SH)flock(LOCK_EX) (e.g., incr/decr)
mycache ships with a WordPress-compatible object-cache.php drop-in. It routes standard
WordPress object cache calls to the extension while maintaining an in-request cache for maximum speed.
wp-content/object-cache.php
mycache can be configured globally in php.ini or per-request via ini_set().
The drop-in uses this to safely bind each host to its own cache directory (multi-tenant isolation).
| Setting | Default | Meaning |
|---|---|---|
mycache.dir |
/dev/shm/mycache |
Base directory for RAM-backed cache files |
mycache.fanout |
256 |
Number of subdirectories (power-of-two, up to 4096) |
mycache.chmod_mode |
504 (octal 0770) |
Directory / file permissions (dirs get SGID for group inheritance) |
mycache.max_bytes |
0 |
Total size limit (0 = unlimited); best-effort eviction above the limit |
/dev/shm is restricted.
mycache_set(key, value, ttl) — store a value with optional TTLmycache_get(key) — read a value (returns null on miss)mycache_exists(key) — fast existence checkmycache_delete(key) — delete a keymycache_flush() — full flush (drop-in may prefer namespace bump)mycache_gc(ttlGrace) — remove expired / invalid entriesmycache_incr/decr(key) — atomic numeric updates (file-locked)mycache_stats() — JSON stats for observabilityWooCommerce generates a high volume of repeated object reads (options, product data, lookups, sessions). mycache reduces database pressure and removes network latency from the caching layer.
Cache reads are local filesystem operations in RAM-backed storage. This eliminates socket overhead and tail latency.
Fewer repeated SQL queries for options, transients, lookups and computed objects. Especially impactful on busy product catalog pages and checkout flows.
Atomic writes + file locks keep data consistent across multiple PHP-FPM workers, even with high parallel traffic.
Check pricing, pick a plan, and install the drop-in. You’ll get updates and technical support with an active license.
View pricing Installation guide