Open-source project
TruCopilot/phpfastcache avatar
TruCopilot/phpfastcache

phpfastcache: one PHP caching API across Redis, Memcached, files and more

A high-performance backend cache system. It is intended for use in speeding up dynamic web applications by alleviating database load. Well implemented, it can drops the database load to almost nothing, yielding faster page load times for users, better resource utilization. It is simple yet powerful.

2,410 stars444 forksPHPMIT

At a glance

What is it?
phpfastcache wraps many cache backends behind a single class, so application code does not change when the storage does. The trade-off is version churn and a driver matrix that is only partly maintained.
Who is it for?
Adopt phpfastcache when you want one caching API in PHP and may switch backends later, and you are already on PHP 8. Do not adopt it if you are pinned to PHP 7, or if you need a driver the README marks deprecated (Wincache, CouchBasev3) or at risk (Cassandra).
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 176 days ago.
What is it written in?
Mainly PHP, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 30, 2026, and from our analysis. They are not legal advice.

Editorial analysis

The problem phpfastcache solves: one cache API instead of one per backend

PHP applications usually start caching in files, move to APCu, then to Redis or Memcached when a second server appears. Each move means rewriting the calls that read and write cached values. phpfastcache exists to remove that rewrite. The README states the intent plainly: "The simplicity of abstraction: One class for many backend cache. You don't need to rewrite your code many times again." The project describes itself as a high-performance backend cache system intended to speed up dynamic web applications by alleviating database load.

The audience is PHP developers maintaining applications where the cache backend is a deployment decision rather than an application decision. If your team argues about Redis versus Memcached, or if a shared host gives you only APCu and files while production runs Redis, the abstraction earns its place. If you have exactly one backend and no intention of changing it, the library is an extra dependency between your code and a client you already understand.

How the driver abstraction works and where the code lives

The repository is organised around a lib/ directory holding the core, with docs/ for driver descriptions and a tests/ tree. The README splits drivers into four groups: regular drivers, high performance drivers, development drivers, and cluster-aggregated drivers. Core drivers ship with the package (Apcu, Files, Leveldb, Memcache(d), Sqlite, Wincache, Zend Disk Cache, Redis, RedisCluster, Predis, Ssdb, CouchBasev3, Zend Memory Cache, plus the Devnull, Devrandom and Memory development drivers). Others live in separate extension repositories, including Arangodb, Dynamodb, Firestore, Couchdb, Mongodb, Solr, Ravendb and Couchbasev4.

That split matters more than the driver list itself. Installing phpfastcache does not install MongoDB or Firestore support. Each extension is its own Composer package, and the README links them individually. The cluster-aggregated drivers (FullReplicationCluster, SemiReplicationCluster, MasterSlaveReplicationCluster, RandomReplicationCluster) are core and describe replication topologies rather than a single server.

The README also flags lifecycle risk in the table itself. Cassandra is marked as possibly deprecated in v10 because the PHP extension is no longer maintained by Datastax. CouchBasev3 will be deprecated as of v10. Wincache is deprecated as of v9.2 and will be removed as of v10. A driver table that carries its own deprecation notices is useful, but it also means the surface area is shrinking at the edges.

Installing phpfastcache and caching a value with the Files driver

Installation goes through Composer, and the package name is phpfastcache/phpfastcache. The README states that V9 requires PHP 8 or higher, so the platform constraint applies before anything else.

bash
composer require phpfastcache/phpfastcache

After that, the README's central claim is that one class covers many backends. The class name is not spelled out in the README excerpt, so confirm it against the docs/ directory and the wiki before writing production code. The configuration system is the part the README is explicit about: V9 replaced the primitive array used in earlier versions with a configuration object. That is the single biggest change to internalise, because every example written for V8 that passes an array will not work unchanged.

The README points to docs/migration/MigratingFromV8ToV9.md as the migration guide and warns that V9 is "relatively" not compatible with previous versions. Read that file before touching an existing cache layer. For a greenfield project, the practical first step is to pick a core driver (Files needs no server, Redis needs a running instance) and confirm the matching PHP extension is loaded on every host, since the driver list mixes pure PHP clients such as Predis with extension-backed clients such as the Redis and Memcached extensions.

The V8 to V9 break and why version pinning is not optional

The release history shows a jump from 9.2.2 in January 2024 to 9.2.3 two days later, then 9.2.4 on 2025-04-30. The last push to the repository was on 2026-04-07. That is a slow but non-zero cadence, and the README's own wording is cautious: V9 is "mostly a PHP 8 type aware update of Phpfastcache with some significant changes."

The significant change is the configuration object. Code written against V8 passes arrays; V9 does not accept them. The README directs readers to the migration guide rather than documenting the new form inline, which means anyone upgrading has to leave the README to find the shape of the replacement. That is a documentation gap worth naming: the single most disruptive change in the release is described in one sentence plus a link.

There is a second constraint. The README notes that some drivers are deprecated or at risk of removal in v10. If your stack depends on Wincache or CouchBasev3, planning a move is part of adopting V9, not an optional cleanup. Libraries that publish a v10 removal schedule are telling you the maintenance cost of those drivers is already accounted for.

What phpfastcache is not: a cache server or a drop-in for every workload

phpfastcache is a client-side abstraction. It does not store anything itself beyond what a driver provides. The Files driver writes to disk, the Memory driver lives in the process, and every distributed driver needs its own server running and reachable. If your problem is that Redis is saturated, phpfastcache will not help; it will faithfully send the same traffic.

The abstraction also costs something. A single API across Redis, Memcached, SQLite and Solr can only expose the intersection of what those backends do well. Backend-specific features (Redis data structures, Memcached's simple key-value semantics, TTL behaviour that differs between drivers) are not the abstraction's concern. When you need a Redis sorted set or a Memcached CAS operation, you drop to the native client and the abstraction stops paying for itself.

Finally, the driver matrix is uneven. Some entries are core, some are extensions, some are deprecated, and one (Relay) is listed with a target date rather than a shipped driver. Treating the table as a menu of equally supported options would be a misreading. The README's own annotations are the evidence.

Alternatives: symfony/cache and using a native client directly

The closest alternative in the PHP ecosystem is symfony/cache, which offers a similar contract-plus-adapters model but is built around PSR-6 and PSR-16 interfaces and integrates with the Symfony framework's service container. phpfastcache advertises PSR-6 and PSR-16 compliance in its badges, so the interface layer is comparable. The difference is packaging: symfony/cache is a framework component with its own release train and framework coupling, while phpfastcache is a standalone package with its own driver extension repositories. If your application is already a Symfony application, the framework component removes a dependency decision. If it is not, phpfastcache does not drag framework code along.

The other real alternative is skipping the abstraction and using a native client such as Predis or the Redis extension directly. That gives you the full backend API and one fewer layer to debug, at the cost of rewriting call sites if the backend ever changes. phpfastcache is worth its weight precisely when that change is plausible.

Licence, maintenance and upgrade cost

phpfastcache is MIT licensed, which permits commercial and closed-source use with the usual requirement to preserve the copyright notice and permission text. The repository carries a LICENCE file at the top level. Nothing here constitutes legal advice; read the file.

The upgrade cost is the configuration object migration. Any codebase on V8 that moves to V9 touches every cache instantiation, and the README does not document the new object's shape inline. The second cost is driver churn: Wincache is deprecated as of v9.2 and scheduled for removal in v10, CouchBasev3 is scheduled for deprecation in v10, and the README raises the same possibility for Cassandra. Budget the migration guide and the driver table as required reading before an upgrade, not after.

Editorial conclusion

Adopt phpfastcache when you want one caching API in PHP and may switch backends later, and you are already on PHP 8. Do not adopt it if you are pinned to PHP 7, or if you need a driver the README marks deprecated (Wincache, CouchBasev3) or at risk (Cassandra). Before writing code, read the V8 to V9 migration guide in docs/migration and confirm the driver you plan to use ships as a core driver or as a separate extension package.

Frequently asked questions

What PHP version does phpfastcache require?

The README states that V9 requires at least PHP 8 or higher to work properly. Earlier major versions supported older PHP releases, but V9 is described as mostly a PHP 8 type aware update.

How do I install phpfastcache?

It is installed with Composer as phpfastcache/phpfastcache. Some drivers, such as MongoDB, DynamoDB and Firestore, are separate extension packages that must be required individually.

Is phpfastcache compatible with code written for version 8?

No. The README says V9 is relatively not compatible with previous versions, and the migration guide at docs/migration/MigratingFromV8ToV9.md is the reference for moving across. The largest change is the configuration system, which is now an object instead of an array.

Which cache backends does phpfastcache support?

Core drivers include Apcu, Files, Leveldb, Memcache(d), Sqlite, Wincache, Zend Disk Cache, Redis, RedisCluster, Predis, Ssdb, CouchBasev3 and Zend Memory Cache, plus the cluster replication drivers. Arangodb, Dynamodb, Firestore, Couchdb, Mongodb, Solr, Ravendb and Couchbasev4 ship as separate extensions.

Official sources

  1. License: MIT
  2. Project website
  3. README
  4. Releases
  5. TruCopilot/phpfastcache on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/trucopilot-phpfastcache.svg)](https://hysenlabs.com/projects/trucopilot-phpfastcache)