Skip to content

Commit

Permalink
Merge pull request #65 from fisdap/master
Browse files Browse the repository at this point in the history
Add support for Couchbase cache driver
  • Loading branch information
guilhermeblanco committed Aug 15, 2014
2 parents 8830be9 + 12d0d81 commit f2bf6a7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Currently, Doctrine 2 allows you to use the following different Cache drivers:

- APC
- Array
- Couchbase
- Memcache
- Xcache

Expand Down
14 changes: 14 additions & 0 deletions library/Bisna/Doctrine/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,20 @@ private function startCacheInstance(array $config = array())

if (method_exists($adapter, 'initialize')) {
$adapter->initialize($config);
} else if ($adapter instanceof \Doctrine\Common\Cache\CouchbaseCache) {

// Couchbase configuration
$hosts = isset($config['options']['hosts']) ? $config['options']['hosts'] : array('localhost');
$user = isset($config['options']['user']) ? $config['options']['user'] : '';
$password = isset($config['options']['password']) ? $config['options']['password'] : '';
$bucket = isset($config['options']['bucket']) ? $config['options']['bucket'] : 'default';
$persistent = isset($config['options']['persistent']) ? $config['options']['persistent'] : true;

// Prevent stupid PHP error of missing extension (if other driver is being used)
$couchbaseClassName = 'Couchbase';
$couchbase = new $couchbaseClassName($hosts, $user, $password, $bucket, $persistent);

$adapter->setCouchbase($couchbase);
} else if ($adapter instanceof \Doctrine\Common\Cache\MemcacheCache) {
// Prevent stupid PHP error of missing extension (if other driver is being used)
$memcacheClassName = 'Memcache';
Expand Down

0 comments on commit f2bf6a7

Please sign in to comment.