33namespace G4 \Mcache \Driver \Couchbase ;
44
55use Couchbase \ClusterOptions ;
6+ use Couchbase \GetOptions ;
67use Couchbase \Cluster ;
78use Couchbase \UpsertOptions ;
89use Couchbase \ReplaceOptions ;
10+ use G4 \Mcache \SerializeTranscoder ;
911
1012class Couchbase4x implements CouchbaseInterface
1113{
@@ -32,8 +34,7 @@ public function delete($key)
3234 return false ;
3335 }
3436 try {
35- $ mutationResult = $ this ->clientFactory ()->defaultCollection ()->remove ($ key );
36- return $ mutationResult ->cas ();
37+ return $ this ->clientFactory ()->defaultCollection ()->remove ($ key )->cas ();
3738 } catch (\Exception $ e ) {
3839 return false ;
3940 }
@@ -44,8 +45,11 @@ public function get($key)
4445 if (!$ this ->clientFactory ()) {
4546 return false ;
4647 }
48+
49+ $ options = new GetOptions ();
50+ $ options ->transcoder (new SerializeTranscoder ());
4751 try {
48- return $ this ->clientFactory ()->defaultCollection ()->get ($ key )->content ();
52+ return $ this ->clientFactory ()->defaultCollection ()->get ($ key, $ options )->content ();
4953 } catch (\Exception $ e ) {
5054 return false ;
5155 }
@@ -58,6 +62,7 @@ public function replace($key, $value, $expiration)
5862 }
5963 $ replaceOptions = (new ReplaceOptions ())
6064 ->expiry ($ expiration );
65+ $ replaceOptions ->transcoder (new SerializeTranscoder ());
6166 try {
6267 $ mutationResult = $ this ->clientFactory ()->defaultCollection ()->replace ($ key , $ value , $ replaceOptions );
6368 return $ mutationResult ->cas ();
@@ -71,8 +76,10 @@ public function set($key, $value, $expiration)
7176 if (!$ this ->clientFactory ()) {
7277 return false ;
7378 }
79+
7480 $ upsertOptions = (new UpsertOptions ())
75- ->expiry ($ expiration );
81+ ->expiry ($ expiration )
82+ ->transcoder (new SerializeTranscoder ());
7683 try {
7784 $ mutationResult = $ this ->clientFactory ()->defaultCollection ()->upsert ($ key , $ value , $ upsertOptions );
7885 return $ mutationResult ->cas ();
0 commit comments