cuephp / cache
a light weight cache lib
0.2.0
2021-12-05 14:14 UTC
Requires
- php: ^7.3||^8.0
- psr/cache: ^1.0
- psr/simple-cache: ^1.0||^2.0
Requires (Dev)
- phpstan/phpstan: ^1.2
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: *
Suggests
- ext-memcached: use the memcached client
- ext-redis: use the phpredis client
- ext-yac: use yac cache server
Provides
- psr/cache-implementation: 1.0
- psr/simple-cache-implementation: 1.0||2.0
README
Suport Storage Engine
- InMemory
- File
- Memcached
- Redis
- Yac
Instanll
compose require cuephp/cache
Cache Usage
use CuePhp\Cache\Engine\InMemoryEngine; use CuePhp\Cache\Config\InMemoryConfig; $config = new InMemoryConfig; $engine = new InMemoryEngine( $config ); $engine->set( 'key', 'value', 10 ); $item = $engine->get('key'); $item->getData(); // return 'value'
Counter Usage
use CuePhp\Cache\Engine\InMemoryEngine; use CuePhp\Cache\Config\InMemoryConfig; $config = new InMemoryConfig; $engine = new InMemoryEngine( $config ); $incrCounter= $engine->incr( 'key' ); $value = $incrCounter->getData(); //return 1 if 'key' not exist $incrCount = $engine->incr('key', 10); $value = $incrCounter->getData(); //return 11