publishing-kit / cache
Cache factory and wrapper for the PublishingKit project
Requires
- php: >=7.4
- psr/cache: ~1.0
Requires (Dev)
- cache/doctrine-adapter: ^1.0
- doctrine/cache: ^1.10
- infection/infection: ^0.15.0
- mockery/mockery: ^1.3
- php-coveralls/php-coveralls: ^2.1
- phpunit/phpunit: >=8.0
- psy/psysh: ^0.9.12
- squizlabs/php_codesniffer: ^3.0
- symfony/cache: ^5.0
- tedivm/stash: ^0.15.2
- vimeo/psalm: ^3.11
This package is auto-updated.
Last update: 2024-10-09 17:21:07 UTC
README
PublishingKit/Cache is a wrapper around a PSR6-compatible caching library to make it more convenient to work with.
In addition, it also provides factory classes for creating instances of the following caches:
tedivm/stash
symfony/cache
doctrine/cache
, via the Doctrine bridge in PHP-Cache
However, the factory classes do not support every driver. If your driver of choice is not supported, feel free to submit a pull request for this.
In theory it should also be easy to add support for other PSR6-compatible caches. Again, if you want to see factory classes added for those caches, please submit a pull request.
Install
Via Composer
$ composer require publishing-kit/cache
Usage
The wrapper can be instantiated by passing in any cache object that implements PSR6:
$wrapper = new PublishingKit\Cache\Services\Cache\Psr6Cache($cache);
The factory classes accept an array describing the cache in question. Here we create a Stash instance using Redis:
$factory = new PublishingKit\Cache\Factories\StashCacheFactory(); $cache = $factory->make([ 'driver' => 'redis', 'servers' => [[ '127.0.0.1', '6379' ]] ]);
And here we do the same for Symfony Cache:
$factory = new SymfonyCacheFactory(); $cache = $factory->make([ 'driver' => 'redis', 'server' => 'redis://127.0.0.1:6379', ]);
Change log
Please see CHANGELOG for more information on what has changed recently.
Testing
$ composer test
Contributing
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
Security
If you discover any security related issues, please email 450801+matthewbdaly@users.noreply.github.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.