当前位置: 首页>>代码示例>>PHP>>正文


PHP igbinary_serialize函数代码示例

本文整理汇总了PHP中igbinary_serialize函数的典型用法代码示例。如果您正苦于以下问题:PHP igbinary_serialize函数的具体用法?PHP igbinary_serialize怎么用?PHP igbinary_serialize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了igbinary_serialize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: test_space

function test_space($testname, $data)
{
    $phplen = strlen(serialize($data));
    $igbinarylen = strlen(igbinary_serialize($data));
    printf("  php     : %5u\n", $phplen);
    printf("  igbinary: %5u (%.02f%%)\n", $igbinarylen, $igbinarylen * 100 / $phplen);
}
开发者ID:somia,项目名称:igbinary,代码行数:7,代码来源:tests.php

示例2: phpSerialize

 /**
  * @param mixed $data Data to serialize
  * @param bool $useIgBinary Use igBinary extension if supported
  *
  * @return string
  */
 protected function phpSerialize($data, $useIgBinary = true)
 {
     if ($this->isIgBinarySupported() && $useIgBinary) {
         return igbinary_serialize($data);
     }
     return serialize($data);
 }
开发者ID:aurimasniekis,项目名称:epwt-traits,代码行数:13,代码来源:SerializerTrait.php

示例3: freeze

 /**
  * Freezes this cache backend.
  *
  * All data in a frozen backend remains unchanged and methods which try to add
  * or modify data result in an exception thrown. Possible expiry times of
  * individual cache entries are ignored.
  *
  * On the positive side, a frozen cache backend is much faster on read access.
  * A frozen backend can only be thawed by calling the flush() method.
  *
  * @return void
  * @throws \RuntimeException
  */
 public function freeze()
 {
     if ($this->frozen === true) {
         throw new \RuntimeException(sprintf('The cache "%s" is already frozen.', $this->cacheIdentifier), 1323353176);
     }
     $cacheEntryFileExtensionLength = strlen($this->cacheEntryFileExtension);
     for ($directoryIterator = new \DirectoryIterator($this->cacheDirectory); $directoryIterator->valid(); $directoryIterator->next()) {
         if ($directoryIterator->isDot()) {
             continue;
         }
         if ($cacheEntryFileExtensionLength > 0) {
             $entryIdentifier = substr($directoryIterator->getFilename(), 0, -$cacheEntryFileExtensionLength);
         } else {
             $entryIdentifier = $directoryIterator->getFilename();
         }
         $this->cacheEntryIdentifiers[$entryIdentifier] = true;
         $cacheEntryPathAndFilename = $this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension;
         $lock = new Lock($cacheEntryPathAndFilename);
         file_put_contents($cacheEntryPathAndFilename, $this->internalGet($entryIdentifier, false));
         $lock->release();
     }
     $cachePathAndFileName = $this->cacheDirectory . 'FrozenCache.data';
     $lock = new Lock($cachePathAndFileName);
     if ($this->useIgBinary === true) {
         file_put_contents($cachePathAndFileName, igbinary_serialize($this->cacheEntryIdentifiers));
     } else {
         file_put_contents($cachePathAndFileName, serialize($this->cacheEntryIdentifiers));
     }
     $lock->release();
     $this->frozen = true;
 }
开发者ID:mkeitsch,项目名称:flow-development-collection,代码行数:44,代码来源:FileBackend.php

示例4: serialize

	protected function serialize ($value) {
		if ($this->igbinary) {
			return igbinary_serialize($value);
		}

		return serialize($value);
	}
开发者ID:4otaku,项目名称:framework,代码行数:7,代码来源:Files.php

示例5: serialize

 public function serialize($data)
 {
     if ($this->igbinary) {
         return igbinary_serialize($data);
     }
     return serialize($data);
 }
开发者ID:rolandinsh,项目名称:apDeliveryCacheRedis,代码行数:7,代码来源:Redis.php

示例6: bench

function bench($value, $n = 1000000)
{
    $benchmark = new Benchmark();
    $benchmark->add('serialize', function () use(&$value) {
        serialize($value);
    });
    $benchmark->add('json_encode', function () use(&$value) {
        json_encode($value);
    });
    if (function_exists('bin_encode')) {
        $benchmark->add('bin_encode', function () use(&$value) {
            bin_encode($value);
        });
    }
    if (function_exists('bson_encode')) {
        $benchmark->add('bson_encode', function () use(&$value) {
            bson_encode($value);
        });
    }
    if (function_exists('msgpack_pack')) {
        $benchmark->add('msgpack_pack', function () use(&$value) {
            msgpack_pack($value);
        });
    }
    if (function_exists('igbinary_serialize')) {
        $benchmark->add('igbinary_serialize', function () use(&$value) {
            igbinary_serialize($value);
        });
    }
    $benchmark->add('var_export', function () use(&$value) {
        var_export($value, true);
    });
    $benchmark->setCount($n);
    $benchmark->run();
}
开发者ID:ovr,项目名称:php-web-benchmarks,代码行数:35,代码来源:serialize.php

示例7: freeze

 /**
  * Freezes this cache backend.
  *
  * All data in a frozen backend remains unchanged and methods which try to add
  * or modify data result in an exception thrown. Possible expiry times of
  * individual cache entries are ignored.
  *
  * On the positive side, a frozen cache backend is much faster on read access.
  * A frozen backend can only be thawed by calling the flush() method.
  *
  * @return void
  * @throws \RuntimeException
  */
 public function freeze()
 {
     if ($this->frozen === TRUE) {
         throw new \RuntimeException(sprintf('The cache "%s" is already frozen.', $this->cacheIdentifier), 1323353176);
     }
     $cacheEntryFileExtensionLength = strlen($this->cacheEntryFileExtension);
     for ($directoryIterator = new \DirectoryIterator($this->cacheDirectory); $directoryIterator->valid(); $directoryIterator->next()) {
         if ($directoryIterator->isDot()) {
             continue;
         }
         if ($cacheEntryFileExtensionLength > 0) {
             $entryIdentifier = substr($directoryIterator->getFilename(), 0, -$cacheEntryFileExtensionLength);
         } else {
             $entryIdentifier = $directoryIterator->getFilename();
         }
         $this->cacheEntryIdentifiers[$entryIdentifier] = TRUE;
         file_put_contents($this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension, $this->get($entryIdentifier));
     }
     if ($this->useIgBinary === TRUE) {
         file_put_contents($this->cacheDirectory . 'FrozenCache.data', igbinary_serialize($this->cacheEntryIdentifiers));
     } else {
         file_put_contents($this->cacheDirectory . 'FrozenCache.data', serialize($this->cacheEntryIdentifiers));
     }
     $this->frozen = TRUE;
 }
开发者ID:adrolli,项目名称:TYPO3.CMS,代码行数:38,代码来源:FileBackend.php

示例8: set

 /**
  * Store data on the cache server.
  *
  * @param string       $key        Key we can use to retrieve the data.
  * @param string|array $data       Data to store on the cache server.
  * @param int          $expiration Time before the data expires on the cache server.
  *
  * @return bool Success/Failure.
  * @access public
  */
 public function set($key, $data, $expiration)
 {
     if ($this->connected === true && $this->ping() === true) {
         return $this->server->set($key, $this->isRedis ? $this->IgBinarySupport ? igbinary_serialize($data) : serialize($data) : $data, $expiration);
     }
     return false;
 }
开发者ID:sebst3r,项目名称:nZEDb,代码行数:17,代码来源:Cache.php

示例9: testSerialize

 /**
  * @dataProvider getTestData
  */
 public function testSerialize($value, $serialized, $expected = null)
 {
     if (!extension_loaded('igbinary')) {
         $this->markTestSkipped('The igbinary extension must be loaded');
     }
     $serialized = igbinary_serialize($value);
     parent::testSerialize($value, $serialized, $expected);
 }
开发者ID:savritsky,项目名称:cache,代码行数:11,代码来源:IgbinarySerializerTest.php

示例10: _tempData_serialize

 private function _tempData_serialize($data)
 {
     if (true === $this->_has_igbinary_status) {
         return igbinary_serialize($data);
     } else {
         return serialize($data);
     }
 }
开发者ID:Bushzhao,项目名称:rvbwebsite,代码行数:8,代码来源:TempData.php

示例11: serialize

 private static function serialize($o)
 {
     $igbinary = extension_loaded('igbinary');
     if ($igbinary) {
         return @igbinary_serialize($o);
     }
     return @serialize($o);
 }
开发者ID:splitice,项目名称:radical-web-event,代码行数:8,代码来源:RedisStorage.php

示例12: serialize

/**
 * @param mixed $val
 * @return string
 */
function serialize($val)
{
    if (function_exists('igbinary_serialize')) {
        return \igbinary_serialize($val);
    } else {
        return \serialize($val);
    }
}
开发者ID:helpfulrobot,项目名称:heystack-heystack,代码行数:12,代码来源:functions.php

示例13: _serialize

 private function _serialize($data)
 {
     if ($this->_has_igbinary) {
         return igbinary_serialize($data);
     } else {
         return serialize($data);
     }
 }
开发者ID:Bushzhao,项目名称:rvbwebsite,代码行数:8,代码来源:PepVN_CacheSimpleFile.php

示例14: unpack

 /**
  */
 public function unpack($data)
 {
     $out = igbinary_unserialize($data);
     if (!is_null($out) || $data == igbinary_serialize(null)) {
         return $out;
     }
     throw new Horde_Pack_Exception('Error when unpacking serialized data.');
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:10,代码来源:Igbinary.php

示例15: sendPacket

 /**
  * @TODO DESCR
  * @param $p
  */
 public function sendPacket($p)
 {
     if ($p === null) {
         return;
     }
     $data = \igbinary_serialize($p);
     $this->write(pack('N', mb_orig_strlen($data)) . $data);
 }
开发者ID:kakserpom,项目名称:phpdaemon,代码行数:12,代码来源:WorkerConnection.php


注:本文中的igbinary_serialize函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。