本文整理汇总了PHP中Memcached::getOption方法的典型用法代码示例。如果您正苦于以下问题:PHP Memcached::getOption方法的具体用法?PHP Memcached::getOption怎么用?PHP Memcached::getOption使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Memcached
的用法示例。
在下文中一共展示了Memcached::getOption方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: write
/**
* {@inheritdoc}
*/
public function write($key, $data, $expires = 60, $compressed = false)
{
$cmp = $this->driver->getOption(Memcached::OPT_COMPRESSION);
$this->driver->setOption(Memcached::OPT_COMPRESSION, $compressed);
$cached = $this->driver->set($key, $data, $expires);
$this->driver->setOption(Memcached::OPT_COMPRESSION, $cmp);
return $cached;
}
示例2: __construct
public function __construct()
{
$this->connect();
if ($this->is_connected) {
$this->memcached->setOption(Memcached::OPT_PREFIX_KEY, _DB_PREFIX_);
if ($this->memcached->getOption(Memcached::HAVE_IGBINARY)) {
$this->memcached->setOption(Memcached::OPT_SERIALIZER, Memcached::SERIALIZER_IGBINARY);
}
}
}
示例3: _doDelete
/**
* Remove a cache record directly. This method is implemented by the cache
* drivers and used in Doctrine_Cache_Driver::delete()
*
* @param string $id cache id
* @return boolean true if no problem
*/
protected function _doDelete($id)
{
if (false == $this->_memcached->getOption(Memcached::OPT_BINARY_PROTOCOL)) {
$id = str_replace(' ', '_', $id);
}
return $this->_memcached->delete($id);
}
示例4: has
/**
* {@inheritdoc }
*/
public function has($key)
{
/* It seems that the most efficient way to check has in memcached is
by using an append with an empty string. However, we need to make
sure that OPT_COMPRESSION is turned off because you can't append
if you compressing data */
/* store for later use */
$cur_compression = $this->adapter->getOption(BaseMemcached::OPT_COMPRESSION);
/* set compression off */
$this->adapter->setOption(BaseMemcached::OPT_COMPRESSION, false);
$res = $this->adapter->append($this->buildKey($key), '');
$this->adapter->setOption(BaseMemcached::OPT_COMPRESSION, $cur_compression);
return $res;
}
示例5: testAddWithPrefixSuccess
public function testAddWithPrefixSuccess()
{
$memcached = new Memcached();
$memcached->setOption(Memcached::OPT_PREFIX_KEY, "widgets_");
$request = new MemcacheSetRequest();
$item = $request->addItem();
$item->setKey("widgets_float");
$item->setValue("2");
$item->setFlags(6);
// float
$item->setSetPolicy(SetPolicy::ADD);
$item->setExpirationTime(30);
$response = new MemcacheSetResponse();
$response->addSetStatus(SetStatusCode::STORED);
$this->apiProxyMock->expectCall('memcache', 'Set', $request, $response);
$this->assertTrue($memcached->add("float", 2.0, 30));
$this->assertEquals($memcached->getOption(Memcached::OPT_PREFIX_KEY), "widgets_");
$this->assertEquals($memcached->getResultCode(), Memcached::RES_SUCCESS);
$this->assertEquals($memcached->getResultMessage(), "SUCCESS");
$this->apiProxyMock->verify();
}
示例6: getOption
/**
* Retrieve a Memcached option value.
*
* @link http://www.php.net/manual/en/memcached.getoption.php
*
* @param int $option One of the Memcached::OPT_* constants.
* @return mixed Returns the value of the requested option, or FALSE on error.
*/
public function getOption($option)
{
return $this->m->getOption($option);
}
示例7: Memcached
<?php
$mc = new Memcached();
$mc->setOption(Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
var_dump($mc->getOption(Memcached::OPT_HASH) === Memcached::HASH_MD5);
var_dump($mc->getOption(Memcached::OPT_DISTRIBUTION) === Memcached::DISTRIBUTION_CONSISTENT_WEIGHTED);
$mc->setOption(Memcached::OPT_LIBKETAMA_COMPATIBLE, false);
var_dump($mc->getOption(Memcached::OPT_HASH) === Memcached::HASH_DEFAULT);
var_dump($mc->getOption(Memcached::OPT_DISTRIBUTION) === Memcached::DISTRIBUTION_MODULA);
示例8: Memcached
<?php
$memc1 = new Memcached("test");
$memc1->setOption(Memcached::OPT_PREFIX_KEY, 'php');
var_dump($memc1->getOption(Memcached::OPT_PREFIX_KEY));
$memc2 = new Memcached("test");
var_dump($memc2->getOption(Memcached::OPT_PREFIX_KEY));
$memc3 = new Memcached();
var_dump($memc3->getOption(Memcached::OPT_PREFIX_KEY));
示例9: Memcached
<?php
$mc = new Memcached();
var_dump(Memcached::OPT_HASH_WITH_PREFIX_KEY);
var_dump($mc->getOption(Memcached::OPT_HASH_WITH_PREFIX_KEY));
var_dump($mc->setOption(Memcached::OPT_HASH_WITH_PREFIX_KEY, true));
var_dump($mc->getOption(Memcached::OPT_HASH_WITH_PREFIX_KEY));
示例10: getOption
/**
* Retrieve a daemon option value.
*
* @link http://www.php.net/manual/en/memcached.getoption.php
*
* @param int $option One of the Memcached::OPT_* constants.
* @return mixed Returns the value of the requested option, or FALSE on error.
*/
public function getOption($option)
{
return $this->daemon->getOption($option);
}