Download the PHP package ez-php/cache without Composer

On this page you can find all versions of the php package ez-php/cache. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package cache

ez-php/cache

Cache module for the ez-php framework — array, file, Redis, and Memcached drivers with a unified interface, tagging, locking, cache statistics, and stampede protection.

CI

Requirements

Installation

Setup

Register the service provider:

Configure in config/cache.php:

Use the module-scoped CACHE_REDIS_* variables, not the generic REDIS_HOST/REDIS_PORT: in an application built from the ez-php/ template, REDIS_PORT is the host-published port (e.g. 6383), while the app container always reaches Redis at redis:6379.

Usage

Basic operations

Values must be null, scalars, or (nested) arrays of those. Every driver throws a CacheException for objects and resources — the File and Redis drivers restore values with allowed_classes => false, so an object could never come back intact. Cache a scalar/array representation instead and rebuild the object after reading it:

Increment / decrement

Both are atomic (Redis: native INCRBY/DECRBY; File/Array/Memcached: read-modify-write) and create the key with a starting value of 0 when it does not already exist.

Tagging

Locking

release() only removes a lock this instance acquired and still owns: if the TTL ran out and another process took the lock meanwhile, the late release() leaves that lock alone. Use forceRelease() for a deliberate hand-off where another process releases (it removes the lock whoever holds it; FileLock can't break another process's flock(), so there it only releases its own).

Stampede protection

Key prefixes

Several applications or tenants sharing one store keep their keys apart with PrefixedCache — or set cache.prefix (CACHE_PREFIX) and the provider wraps the configured driver for you:

Keys, locks and tags are prefixed. flush() still empties the whole underlying store (every prefix); tag entries and flush the tag to invalidate one prefix.

Console commands

With an ez-php application (and ez-php/console, which the framework already requires), CacheServiceProvider registers:

With the apcu driver cache:clear exits 1 instead: the console has its own APCu memory and cannot reach the PHP-FPM workers' cache. Restart PHP-FPM, or flush from a web request. For the same reason, values a queue worker or other CLI process writes to APCu are never seen by web requests.

cache:prune is a no-op on stores that evict on their own (array, file, Redis, Memcached).

Drivers

Driver CACHE_DRIVER Notes
array array In-memory, request lifetime only
file file Filesystem, serialised entries
redis redis Via ext-redis; flush() clears entire database
memcached memcached Via ext-memcached; flush() clears entire server
apcu apcu Via ext-apcu (CLI: apc.enable_cli=1); shared by the PHP-FPM workers of one host — not with CLI processes, each of which gets its own short-lived APCu memory; atomic counters; flush() clears the APCu user cache
database database On the bound DatabaseInterface; tables cache/cache_locks auto-created (MySQL, SQLite, PostgreSQL); flush() empties only the cache table

Classes

Class Description
CacheInterface Unified contract: get, set, forget, has, remember, flush, increment, decrement
ArrayDriver In-memory driver
FileDriver Filesystem driver with MD5-keyed files
RedisDriver Redis driver via ext-redis; native TTL
MemcachedDriver Memcached driver via ext-memcached
ApcuDriver Shared-memory driver via ext-apcu (one host)
DatabaseDriver Database driver on DatabaseInterface; auto-created tables; run cache:prune (or prune()) periodically to delete expired rows that are never read again
PrunableCacheInterface prune(): int — implemented by DatabaseDriver
CacheClearCommand / CachePruneCommand cache:clear [--tags=…] / cache:prune
FileLock / ArrayLock / RedisLock / MemcachedLock / DatabaseLock / ApcuLock Driver-specific lock implementations
TaggableDriverTrait Provides tags() → TaggedCache for all drivers
TaggedCache Tag-scoped decorator: records keys per tag; flush() invalidates the group
CacheStats Immutable value object: hits, misses
CacheValue Value-contract guard used by every driver's set(): rejects objects and resources
StampedeProtectedCache Decorator: probabilistic early recompute to prevent stampedes
PrefixedCache Decorator: prefixes every key, lock and tag list; wired by cache.prefix
CacheServiceProvider Config-driven driver binding

License

MIT — Andreas Uretschnig


All versions of cache with dependencies

PHP Build Version
Package Version
Requires php Version ^8.5
ez-php/contracts Version ^2.7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ez-php/cache contains the following files

Loading the files please wait ...