PHP code example of lavoiesl / doctrine-cache-provider

1. Go to this page and download the library: Download lavoiesl/doctrine-cache-provider 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/ */

    

lavoiesl / doctrine-cache-provider example snippets



use Lavoiesl\Doctrine\CacheProvider\DoctrineCache;

// Doctrine config
$config = new \Doctrine\DBAL\Configuration();
$connectionParams = array(
    'dbname' => 'mydb',
    'user' => 'user',
    'password' => 'secret',
    'host' => 'localhost',
    'driver' => 'pdo_mysql',
);
$conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config);


// DoctrineCache config
$fields = array(
    'id'         => 'name',
    'data'       => 'data',
    'expiration' => 'expiration',
);

$cache = new DoctrineCache($conn, 'my_table_cache', $fields);
$cache->save('key', $value, $ttl);
$cache->fetch('key');



use Lavoiesl\Doctrine\CacheProvider\CacheSchema;

CacheSchema::createTable($connection, 'my_table_cache', $fields);