Skip to content

Commit

Permalink
Merge pull request #542 from Geolim4/final
Browse files Browse the repository at this point in the history
Fixed #541
  • Loading branch information
Geolim4 committed Nov 23, 2017
2 parents 0cc9e80 + 1add56e commit c3061be
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/phpFastCache/Drivers/Couchbase/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ protected function driverWrite(CacheItemInterface $item)
* Check for Cross-Driver type confusion
*/
if ($item instanceof Item) {
return $this->getBucket()->upsert($item->getEncodedKey(), $this->encode($this->driverPreWrap($item)), ['expiry' => $item->getTtl()]);
try {
return (bool)$this->getBucket()->upsert($item->getEncodedKey(), $this->encode($this->driverPreWrap($item)), ['expiry' => $item->getTtl()]);
} catch (\CouchbaseException $e) {
return false;
}
} else {
throw new phpFastCacheInvalidArgumentException('Cross-Driver type confusion detected');
}
Expand Down Expand Up @@ -111,7 +115,11 @@ protected function driverDelete(CacheItemInterface $item)
* Check for Cross-Driver type confusion
*/
if ($item instanceof Item) {
return $this->getBucket()->remove($item->getEncodedKey());
try {
return (bool)$this->getBucket()->remove($item->getEncodedKey());
} catch (\Couchbase\Exception $e) {
return $e->getCode() === COUCHBASE_KEY_ENOENT;
}
} else {
throw new phpFastCacheInvalidArgumentException('Cross-Driver type confusion detected');
}
Expand Down

0 comments on commit c3061be

Please sign in to comment.