codeigniter4 / cache
PSR-6 and PSR-16 Cache Adapters for CodeIgniter 4
Installs: 10 880
Dependents: 0
Suggesters: 0
Security: 0
Stars: 9
Watchers: 8
Forks: 4
Open Issues: 3
Requires
- php: ^7.3 || ^8.0
- psr/cache: ^1.0
- psr/simple-cache: ^1.0
Requires (Dev)
- cache/integration-tests: ^0.17.0
- codeigniter/coding-standard: ^1.1
- codeigniter4/codeigniter4: dev-develop
- nexusphp/cs-config: ^3.1
- nexusphp/tachycardia: ^1.0
- php-coveralls/php-coveralls: ^2.4
- phpstan/phpstan: ^0.12
- phpunit/phpunit: ^9.5
- roave/security-advisories: dev-latest
Provides
This package is auto-updated.
Last update: 2024-12-11 12:09:45 UTC
README
PSR-6 and PSR-16 Cache Adapters for CodeIgniter 4
Disclaimer: CodeIgniter 4 comes with a fully-functional cache component! This module is only for integrating third-party packages that rely on the PSR interface provisions.
Quick Start
- Install with Composer:
> composer require codeigniter4/cache
- Integrate with your favorite packages:
use CodeIgniter\Psr\Cache\SimpleCache; use Kreait\Firebase\Factory; ... $factory = (new Factory)->withVerifierCache(new SimpleCache());
Features
A set of adapters fully-compliant with PSR-6 and PSR-16 to integrate with CodeIgniter 4's Caching Driver.
Installation
Install easily via Composer to take advantage of CodeIgniter 4's autoloading capabilities and always be up-to-date:
> composer require codeigniter4/cache
Or, install manually by downloading the source files and adding the directory to
app/Config/Autoload.php
.
Usage
This module has adapters for CodeIgniter 4 to supply the following FIG PHP Standards Recommendations (PSR):
If you just need a caching agent then you should use the framework's native Caching Driver. These adapters are intended to integrate with any library or project that requires either of the following:
The interfaces are provided by the following classes:
Psr\Cache\CacheItemInterface
provided byCodeIgniter\Psr\Cache\Item
Psr\Cache\CacheItemPoolInterface
provided byCodeIgniter\Psr\Cache\Pool
Psr\SimpleCache\CacheInterface
provided byCodeIgniter\Psr\Cache\SimpleCache
By default the adapters (Pool
and SimpleCache
) will work with the Caching Driver as defined
in you cache configuration (e.g. app/Config/Cache.php). You may create either driver explicitly
with an alternative Cache Handler or Config:
$sharedCacheServicePool = new \CodeIgniter\Psr\Cache\Pool(); $fileHandler = new \CodeIgniter\Cache\Handlers\FileHandler(config('Cache')); $explicitFileHandlerSimpleCache = new \CodeIgniter\Psr\Cache\SimpleCache($fileHandler); $config = config('Cache'); $config->prefix = 'banana-'; $alternativeConfigPool = new \CodeIgniter\Psr\Cache\Pool($config);
Testing
Testing of the underlying Caching Driver is handled in the CodeIgniter 4 repo. These adapters are tested with the PHP Cache Integration Tests, by Aaron Scherer. You may run the test suite by cloning this repo, installing all dependencies, and running:
> composer test