Skip to content

Commit c3061be

Browse files
authored
Merge pull request #542 from Geolim4/final
Fixed #541
2 parents 0cc9e80 + 1add56e commit c3061be

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/phpFastCache/Drivers/Couchbase/Driver.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ protected function driverWrite(CacheItemInterface $item)
7878
* Check for Cross-Driver type confusion
7979
*/
8080
if ($item instanceof Item) {
81-
return $this->getBucket()->upsert($item->getEncodedKey(), $this->encode($this->driverPreWrap($item)), ['expiry' => $item->getTtl()]);
81+
try {
82+
return (bool)$this->getBucket()->upsert($item->getEncodedKey(), $this->encode($this->driverPreWrap($item)), ['expiry' => $item->getTtl()]);
83+
} catch (\CouchbaseException $e) {
84+
return false;
85+
}
8286
} else {
8387
throw new phpFastCacheInvalidArgumentException('Cross-Driver type confusion detected');
8488
}
@@ -111,7 +115,11 @@ protected function driverDelete(CacheItemInterface $item)
111115
* Check for Cross-Driver type confusion
112116
*/
113117
if ($item instanceof Item) {
114-
return $this->getBucket()->remove($item->getEncodedKey());
118+
try {
119+
return (bool)$this->getBucket()->remove($item->getEncodedKey());
120+
} catch (\Couchbase\Exception $e) {
121+
return $e->getCode() === COUCHBASE_KEY_ENOENT;
122+
}
115123
} else {
116124
throw new phpFastCacheInvalidArgumentException('Cross-Driver type confusion detected');
117125
}

0 commit comments

Comments
 (0)