PHP code example of phalcon / bridge-psr16

1. Go to this page and download the library: Download phalcon/bridge-psr16 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/ */

    

phalcon / bridge-psr16 example snippets


use Phalcon\Bridge\Psr16\Cache;
use Phalcon\Cache\AdapterFactory;
use Phalcon\Storage\SerializerFactory;

$serializerFactory = new SerializerFactory();
$adapterFactory    = new AdapterFactory($serializerFactory);
$adapter           = $adapterFactory->newInstance('memory');

$cache = new Cache($adapter);

// $cache is a Psr\SimpleCache\CacheInterface
$cache->set('user.42', ['name' => 'Phalcon'], 3600);
$data = $cache->get('user.42');

use Phalcon\Bridge\Psr16\Adapter;
use Phalcon\Cache\Cache;
use Phalcon\Storage\SerializerFactory;

// Any Psr\SimpleCache\CacheInterface, e.g. Symfony's Psr16Cache
$psr = new Symfony\Component\Cache\Psr16Cache(/* ... */);

$adapter = new Adapter(new SerializerFactory(), $psr);
$cache   = new Cache($adapter);

// Phalcon cache calls now flow into the PSR-16 cache
$cache->set('key', 'value');