phico / cache
Lightweight cache server support for Phico
dev-main
2024-08-06 15:32 UTC
Requires
- php: ^8.0
- phico/config: dev-main
- predis/predis: ^2.2
Requires (Dev)
- pestphp/pest: ^2.34
- phpstan/phpstan: ^1.11
This package is auto-updated.
Last update: 2024-11-06 16:06:30 UTC
README
Lightweight cache support for Phico
Installation
Using composer
composer require phico/cache
Config
Cache requires a specific config format for each driver
[ 'use' => env('CACHE_USE', 'default'), 'drivers' => [ 'file' => [ 'path' => env('CACHE_FILESYSTEM_PATH', '/storage/cache'), ], 'redis' => [ 'scheme' => env('CACHE_REDIS_SCHEME', 'tcp'), 'host' => env('CACHE_REDIS_HOST', '127.0.0.1'), 'port' => env('CACHE_REDIS_PORT', 6379), ], ], ];
Usage
Cache provides quick and simple access to cache servers such as Redis, KeyDB and Valkey.
$use = $config['use']; $cache = new Cache($config['drivers'][$use]); $cache->set('foo', 'bar'); $value = $cache->get('foo'); // $value = 'bar' $cache->delete('foo'); $exists = $cache->exists('foo'): // $exists = false
Issues
If you discover any bugs or issues with behaviour or performance please create an issue, and if you are able a pull request with a fix.
Please make sure to update tests as appropriate.
For major changes, please open an issue first to discuss what you would like to change.