Beispiel #1
0
 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);
 }
/**
 * The default decoder for the client.  Currently invokes the
 * v1 decoder directly.
 *
 * @internal
 */
function couchbase_default_decoder($bytes, $flags, $datatype)
{
    global $COUCHBASE_DEFAULT_DECOPTS;
    return couchbase_basic_decoder_v1($bytes, $flags, $datatype, $COUCHBASE_DEFAULT_DECOPTS);
}