public function init() { $this->parentInit(); if (!$this->storage instanceof \CouchbaseBucket) { $this->storage = (new \CouchbaseCluster($this->normalizeServers($this->servers), $this->username, $this->password))->openBucket($this->bucket); } switch ($this->serializer) { case self::SERIALIZE_JSON: $encode = 'couchbase_default_encoder'; $decode = function ($bytes, $flags, $datatype) { $options = ['jsonassoc' => true]; return couchbase_basic_decoder_v1($bytes, $flags, $datatype, $options); }; break; default: $encode = function ($value) { $options = ['sertype' => COUCHBASE_SERTYPE_PHP, 'cmprtype' => COUCHBASE_CMPRTYPE_NONE, 'cmprthresh' => 2000, 'cmprfactor' => 1.3]; return couchbase_basic_encoder_v1($value, $options); }; $decode = 'couchbase_default_decoder'; } $this->storage->setTranscoder($encode, $decode); }
/** * @param $value * * @return mixed */ function couchbase_php_serialize_encoder($value) { return couchbase_basic_encoder_v1($value, ['sertype' => COUCHBASE_SERTYPE_PHP, 'cmprtype' => COUCHBASE_CMPRTYPE_NONE, 'cmprthresh' => 0, 'cmprfactor' => 0]); }
/** * The default encoder for the client. Currently invokes the * v1 encoder directly with the default set of encoding options. * * @internal */ function couchbase_default_encoder($value) { global $COUCHBASE_DEFAULT_ENCOPTS; return couchbase_basic_encoder_v1($value, $COUCHBASE_DEFAULT_ENCOPTS); }