Unified PSR-16 Cache abstraction for the Quill PHP Framework.
This package provides a simplified caching interface with support for multiple backends, allowing you to switch between in-memory, local filesystem, or distributed storage with a single configuration change.
composer require quillphp/cache- PSR-16 Compliant: Implements the standard
Psr\SimpleCache\CacheInterface. - Multiple Drivers:
ArrayDriver: In-memory caching for testing or single-request lifecycles.FileDriver: Persistent filesystem-based caching.ApcuDriver: High-performance shared memory caching via APCu.RedisDriver: Distributed caching via Redis.
- CacheManager: Fluent API for managing and selecting active drivers.
- Service Provider: Automatic integration with the Quill DI container.
use Quill\Cache\CacheManager;
use Quill\Cache\ArrayDriver;
$cache = new CacheManager('array');
$cache->addDriver('array', new ArrayDriver());
$cache->set('key', 'value', 3600);
$value = $cache->get('key');Register the cache system using the CacheServiceProvider:
use Quill\Cache\CacheServiceProvider;
$app = new \Quill\App();
CacheServiceProvider::register($app, [
'driver' => 'file',
'path' => __DIR__ . '/storage/cache',
'prefix' => 'my_app:'
]);
// Access via DI in handlers:
$app->get('/data', function(\Quill\Cache\CacheManager $cache) {
return $cache->get('some_data');
});$driver = new \Quill\Cache\FileDriver(__DIR__ . '/cache');$driver = new \Quill\Cache\ApcuDriver('prefix:');Requires a Redis instance (ext-redis or compatible):
$redis = new \Redis();
$redis->connect('127.0.0.1');
$driver = new \Quill\Cache\RedisDriver($redis, 'prefix:');This package is open-sourced software licensed under the MIT license.