quillphp/cache

Unified PSR-16 cache abstraction for the Quill PHP framework

Maintainers

Package info

github.com/quillphp/quill-cache

Homepage

pkg:composer/quillphp/cache

Statistics

Installs: 11

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

0.0.1 2026-04-06 13:40 UTC

This package is auto-updated.

Last update: 2026-04-06 13:41:30 UTC


README

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.

Installation

composer require quillphp/cache

Features

  • 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.

Usage

Basic Caching

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');

Integration with Quill App

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');
});

Available Drivers

File Driver

$driver = new \Quill\Cache\FileDriver(__DIR__ . '/cache');

APCu Driver

$driver = new \Quill\Cache\ApcuDriver('prefix:');

Redis Driver

Requires a Redis instance (ext-redis or compatible):

$redis = new \Redis();
$redis->connect('127.0.0.1');

$driver = new \Quill\Cache\RedisDriver($redis, 'prefix:');

License

This package is open-sourced software licensed under the MIT license.