Skip to content

Commit f2bf6a7

Browse files
Merge pull request #65 from fisdap/master
Add support for Couchbase cache driver
2 parents 8830be9 + 12d0d81 commit f2bf6a7

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

README.markdown

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ Currently, Doctrine 2 allows you to use the following different Cache drivers:
6969

7070
- APC
7171
- Array
72+
- Couchbase
7273
- Memcache
7374
- Xcache
7475

library/Bisna/Doctrine/Container.php

+14
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,20 @@ private function startCacheInstance(array $config = array())
611611

612612
if (method_exists($adapter, 'initialize')) {
613613
$adapter->initialize($config);
614+
} else if ($adapter instanceof \Doctrine\Common\Cache\CouchbaseCache) {
615+
616+
// Couchbase configuration
617+
$hosts = isset($config['options']['hosts']) ? $config['options']['hosts'] : array('localhost');
618+
$user = isset($config['options']['user']) ? $config['options']['user'] : '';
619+
$password = isset($config['options']['password']) ? $config['options']['password'] : '';
620+
$bucket = isset($config['options']['bucket']) ? $config['options']['bucket'] : 'default';
621+
$persistent = isset($config['options']['persistent']) ? $config['options']['persistent'] : true;
622+
623+
// Prevent stupid PHP error of missing extension (if other driver is being used)
624+
$couchbaseClassName = 'Couchbase';
625+
$couchbase = new $couchbaseClassName($hosts, $user, $password, $bucket, $persistent);
626+
627+
$adapter->setCouchbase($couchbase);
614628
} else if ($adapter instanceof \Doctrine\Common\Cache\MemcacheCache) {
615629
// Prevent stupid PHP error of missing extension (if other driver is being used)
616630
$memcacheClassName = 'Memcache';

0 commit comments

Comments
 (0)