GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - ephpm/cache-cakephp: CakePHP 5 cache engine backed by ePHPm built-in in-process KV store (native ephpm_kv_* functions)

BranchesTags
Open more actions menu

Latest commit

 

History

1 Commit
1 Commit

Folders and files

NameName
Last commit message
Last commit date
src
src
 
 
stubs
stubs
 
 
tests
tests
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
composer.json
composer.json
 
 
phpunit.xml.dist
phpunit.xml.dist
 
 

Repository files navigation

cache-cakephp

A CakePHP 5 cache engine backed by ePHPm's built-in, in-process KV store — through ePHPm's native ephpm_kv_* PHP functions. No phpredis extension, no TCP socket, no RESP round-trip, no AUTH: the KV handle is already bound to the running tenant's keyspace, so reads and writes are direct in-process calls.

It is the CakePHP sibling of ephpm/cache-wordpress, and the in-process equivalent of pointing CakePHP's stock RedisEngine at ePHPm's RESP listener — but faster and with nothing to install.

Install

composer require ephpm/cache-cakephp

Until it is on Packagist, add the repo:

{
  "repositories": [
    { "type": "vcs", "url": "https://github.com/ephpm/cache-cakephp" }
  ]
}

Use

Wire it as a cache engine, ideally only when the native API is present, with a fallback for CLI / non-ePHPm contexts:

use Cake\Cache\Cache;
use Ephpm\Cache\Cake\EphpmKvEngine;

Cache::setConfig('default', function_exists('ephpm_kv_get')
    ? ['className' => EphpmKvEngine::class, 'prefix' => 'myapp_', 'duration' => '+1 hour']
    : ['className' => 'File', 'path' => CACHE]); // CLI / dev fallback

Then use Cache as usual — read, write, add, increment, decrement, delete, clear, and groups all work.

Config

Standard CakePHP cache options apply:

key meaning
duration default TTL (seconds, or a strtotime string like '+1 hour'). 0 = no expiry
prefix key prefix (keep distinct per app/config)
groups group tags for Cache::clearGroup()
allowedClasses allowed_classes for unserialize() on read — false to forbid objects (safe for scalar/array caches), or a list of FQCNs
ops (testing) inject a KvOpsInterface, e.g. InMemoryKvOps

How it works

  • Serialization. Integers are stored as their raw decimal string so increment()/decrement() operate on native integers via ephpm_kv_incr_by; everything else is PHP-serialize()d. (The same trick CakePHP's RedisEngine uses.) On read, an integer-looking string comes back as an int, otherwise unserialize().
  • Atomicity. add() maps to ephpm_kv_setnx (atomic set-if-absent), not a read-then-write.
  • Groups. clearGroup() bumps a per-group generation counter folded into the key prefix (CakePHP's standard mechanism), so a group is invalidated without enumerating keys. Stale entries age out by TTL.
  • clear() flushes this tenant's entire keyspace via ephpm_kv_flush_all. ePHPm namespaces the KV per tenant, so it does not touch other sites running on the same ePHPm instance.
  • Testability. The raw calls sit behind KvOpsInterface; SapiKvOps is the real backend and InMemoryKvOps is an array fake for unit tests on a plain PHP runtime.

Caveats

  • Serving process only. ephpm_kv_* exist inside the ePHPm HTTP server, not under the ephpm php CLI. SapiKvOps throws if the functions are absent, so EphpmKvEngine::init() returns false there — select the engine conditionally (as above) and fall back. For CLI/cron work that must touch the KV, reach a running server over its RESP listener (phpredis) instead, or trigger the work over HTTP.
  • Tier-1 cache. The store is an in-process map; entries do not survive a server restart. Treat it as a cache, never as durable storage.

Test

composer install
composer test

The suite runs entirely on InMemoryKvOps, so it needs neither ePHPm nor phpredis.

License

MIT.

About

CakePHP 5 cache engine backed by ePHPm built-in in-process KV store (native ephpm_kv_* functions)

Resources

Readme
MIT license
Activity
Custom properties

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.