Last active
February 25, 2017 05:09
-
-
Save Saeven/31fd88b3a02c12a7c12299b38f4b98bd to your computer and use it in GitHub Desktop.
Doctrine & Memcached
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Typical database config | |
*/ | |
// .... | |
'doctrine' => [ | |
'configuration' => [ | |
'orm_default' => [ | |
'metadata_cache' => 'memcached', | |
'query_cache' => 'memcached', | |
'result_cache' => 'memcached', | |
'datetime_functions' => [ | |
'Date' => Date::class, | |
], | |
], | |
], | |
'cache' => [ | |
'memcached' => [ | |
'instance' => 'doctrine.cache.memcached', | |
], | |
], | |
'connection' => [ | |
'orm_default' => [ | |
'driverClass' => '\Application\Model\Doctrine\DBAL\Driver\PDOMySql\Driver', | |
'wrapperClass' => '\Application\Model\Doctrine\DBAL\Connection', | |
'params' => [ | |
'host' => '***', | |
'port' => '3306', | |
'user' => '***', | |
'password' => '***', | |
'dbname' => '***', | |
'driverOptions' => [ | |
'x_reconnect_attempts' => 10, | |
1002 => 'SET NAMES utf8', | |
], | |
], | |
], | |
], | |
], | |
// .... | |
/* | |
* Factory for cache adapter | |
*/ | |
// .... | |
'service_manager' => [ | |
'factories' => [ | |
'doctrine.cache.memcached' => function ($sm) { | |
$cache = new \Doctrine\Common\Cache\MemcachedCache(); | |
$memcached = new \Memcached(); | |
$memcached->addServer('localhost', 11211); | |
$cache->setMemcached($memcached); | |
return $cache; | |
}, | |
], | |
], | |
// .... | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment