quillphp/cache
最新稳定版本:0.0.1
Composer 安装命令:
composer require quillphp/cache
包简介
Unified PSR-16 cache abstraction for the Quill PHP framework
README 文档
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.
统计信息
- 总下载量: 16
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 5
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-06