tleckie / cache
PSR-6 and PSR-16 Couchbase cache adapter
Fund package maintenance!
teodoroleckie
www.paypal.com/donate?business=ZHYA2MTGA4884¤cy_code=USD
Requires
- ext-couchbase: *
- ext-json: *
- couchbase/couchbase: ^3.1
- psr/cache: ^1.0|^2.0
- psr/simple-cache: ^1.0
Requires (Dev)
- phpunit/phpunit: ^9.5
README
<?php include_once "vendor/autoload.php"; use Couchbase\Cluster; use Couchbase\ClusterOptions; use Tleckie\Cache\Couchbase\Client; use Tleckie\Cache\Couchbase\Psr16\Psr16Cache; use Tleckie\Cache\Couchbase\Psr6\Item; use Tleckie\Cache\Couchbase\Psr6\Pool; $options = new ClusterOptions(); $options->credentials("user", "pass"); $client = new Client(new Cluster("couchbase://localhost/", $options), 'bucketName'); //psr6 $pool = new Pool($client); $item = new Item('item.key'); $item->set(['name'=> 'My Name', 'age' => 32]); $item->expiresAt(3600); $pool->save($item); $item = $pool->getItem('item.key'); var_dump($item); var_dump($item->get()); var_dump($item->isHit()); //psr16 $cache = new Psr16Cache($client); $cache->set( 'key', ['name'=> 'My Name', 'age' => 32], 3600 ); var_dump($cache->get('key'));