PHP code example of codin / stash

1. Go to this page and download the library: Download codin/stash library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

codin / stash example snippets


use Codin\Stash\{
	Item,
	Adapter\RedisPool
    Adapter\Redis\ConnectionResolver
};

$resolver = new ConnectionResolver(static function () {
    return new Redis();
});
$pool = new RedisPool($resolver);

$item = new Item('my-key', 'some data');
$item->expiresAfter(3600); // 1 hour

$pool->save($item);

$item = $pool->getItem('my-key');
echo $item->get(); // some data
echo $item->isHit(); // true
shell
php bin/phpstan
php bin/phpspec run