mrcnpdlk / psr16cache-adapter
Cache adapter for PSR-16
Installs: 29 281
Dependents: 6
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 1
Open Issues: 0
Requires
- php: >=7.2
- ext-json: *
- psr/log: ^1||^2||^3
- psr/simple-cache: ^1.0||^2.0||^3.0
Requires (Dev)
- monolog/monolog: ^1.23
- phpfastcache/phpfastcache: ^6
- phpunit/phpunit: ^6
This package is not auto-updated.
Last update: 2024-12-09 16:51:44 UTC
README
PSR-16 Cache Adapter
Instalation
composer require mrcnpdlk/psr16cache-adapter
Basic usage
$oInstanceCacheFile = new \phpFastCache\Helper\Psr16Adapter( 'files', [ "host" => null, // default localhost "port" => null, // default 6379 'defaultTtl' => 3600 * 24, // 24h 'ignoreSymfonyNotice' => true, ]); $oInstanceLogger = new \Monolog\Logger('name_of_my_logger'); $oInstanceLogger->pushHandler(new \Monolog\Handler\ErrorLogHandler( \Monolog\Handler\ErrorLogHandler::OPERATING_SYSTEM, \Psr\Log\LogLevel::DEBUG ) ); $oCacheAdapter = new \mrcnpdlk\Psr16Cache\Adapter($oInstanceCacheFile, $oInstanceLogger); $oCacheAdapter->setHashSalt(['some_hash', __DIR__]); $res = $oCacheAdapter->useCache( function () { return '1'; }, ['key1', 'key2'], 10 ); var_dump($res);
Response
[2017-10-16 19:17:41] name_of_my_logger.DEBUG: CACHE [ffe7efd40ef900c95726a859aa28e048]: old, reset [] []
string(1) "1"
[2017-10-16 19:17:44] name_of_my_logger.DEBUG: CACHE [ffe7efd40ef900c95726a859aa28e048]: getting from cache [] []
string(1) "1"
Running the tests
./vendor/bin/phpunit
Authors
- Marcin Pudełek - Initial work - mrcnpdlk
See also the list of contributors who participated in this project.
License
This project is licensed under the MIT License - see the LICENSE file for details