Download the PHP package hypernic/filecache without Composer
On this page you can find all versions of the php package hypernic/filecache. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hypernic/filecache
More information about hypernic/filecache
Files in hypernic/filecache
Package filecache
Short Description Hypernic FileCache is a lightweight file-based caching library for PHP 8+
License MIT
Homepage https://github.com/hypernic/filecache
Informations about the package filecache
Hypernic FileCache
FileCache is a lightweight file-based caching library for PHP 8+. It is designed to be fast, cross-platform, and safe with features such as default cache root in sys_get_temp_dir(), sharded directory structure based on sha1(key), TTL handled via filemtime(), atomic writes (LOCK_EX + rename()), conditional compression (gzencode/gzdecode), optional APCu support for hot values (with filesystem fallback), and a simple API (set, get, delete, flush, increment, decrement, replace).
Installation
Install with Composer: `
Or copy FileCache.php directly into your project.
Usage Example
Configuration
Pass config options via constructor or with changeConfig():
API
set(string $key, mixed $value, int $expiry=0)→ store a cache entry (0=10 years,>30 days=timestamp, else seconds).get(string $key)→ retrieve value orfalseif missing/expired.delete(string $key)→ delete one entry.flush()→ clear all entries (keeps.keepfiles).increment(string $key, int $offset=1)→ increment numeric value.decrement(string $key, int $offset=1)→ decrement numeric value.replace(string $key, mixed $value, int $expiry=0)→ replace only if entry exists.changeConfig(array $config)→ update configuration.
Testing
Run PHPUnit tests:
Notes
- APCu is optional; if not installed, FileCache falls back to filesystem.
- Files named
.keepinside cache directories are ignored byflush()so directories remain in version control. - For maximum performance, place the cache directory on a
tmpfs(Linux).