本文整理汇总了PHP中Memcached::getResultMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP Memcached::getResultMessage方法的具体用法?PHP Memcached::getResultMessage怎么用?PHP Memcached::getResultMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Memcached
的用法示例。
在下文中一共展示了Memcached::getResultMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
parent::setUp();
$this->memcache = new \Memcached();
$this->memcache->addServer(self::TEST_MEMCACHE_SERVER, self::TEST_MEMCACHE_PORT);
$this->memcache->flush();
if (!$this->memcache->set('test', 1, time() + 100)) {
throw new \RuntimeException('Cannot save item to memcache. ' . $this->memcache->getResultMessage());
}
}
示例2: _execute
/**
* {@inheritDoc}
*/
protected function _execute(\Closure $action, $operation, $key_or_keys, $mutable = false, $value = null)
{
$result = parent::_execute($action, $operation, $key_or_keys, $mutable, $value);
// Adapter connection itself will only report correctly when not currently buffering results
if (!$this->isBuffering()) {
$code = $this->_connection->getResultCode();
if ($code !== \Memcached::RES_SUCCESS) {
$this->_handleFailure($this->_connection->getResultMessage(), null, null, $code);
}
}
// if !isBuffering
return $result;
}
示例3: __construct
public function __construct($host, $port, $id = 'story_pool')
{
parent::__construct($id);
if (!parent::addServer($host, $port)) {
throw new Exception("Could not connect memcached server {$host}:{$port}." . "\n" . 'Error code: ' . parent::getResultCode() . "\n" . ' Error message: ' . parent::getResultMessage());
}
parent::setOption(Memcached::OPT_BINARY_PROTOCOL, true);
}
示例4: verifyReturnCode
/**
* @throws \Exception
*/
private function verifyReturnCode()
{
$code = self::$cache->getResultCode();
if ($code === \Memcached::RES_SUCCESS) {
return;
}
$message = self::$cache->getResultMessage();
throw new \Exception("Error {$code} interacting with memcached : {$message}");
}
示例5: set
/**
* @param $key
* @param $value
*
* @return bool
* @throws Exception
*/
public function set($key, &$value)
{
$key = $this->cleanKey($key);
if (!$this->_cache->set($key, $value, $this->_timeout)) {
CRM_Core_Error::debug('Result Code: ', $this->_cache->getResultMessage());
CRM_Core_Error::fatal("memcached set failed, wondering why?, {$key}", $value);
return FALSE;
}
return TRUE;
}
示例6: addServer
/**
* Add a Memcached server to stack
*
* @param string $server Server address (or IP)
* @param string $port Server port
* @param string $weight Server weight
*/
private function addServer($server, $port, $weight)
{
$status = $this->instance->addServer($server, $port, $weight);
if ($status === false) {
$this->raiseError("Error communicating with server", array("RESULTCODE" => $this->instance->getResultCode(), "RESULTMESSAGE" => $this->instance->getResultMessage()));
}
if (sizeof($this->instance->getServerList()) == 0) {
$this->raiseError("No available server, disabling cache administratively");
$this->disable();
} else {
$this->enable();
}
}
示例7: GetMemCachedObj
function GetMemCachedObj()
{
static $MemCachedObj;
if (!$MemCachedObj) {
$MemCachedObj = new Memcached();
if (!$MemCachedObj->addServer(MEMCACHED_HOST, MEMCACHED_PORT)) {
throw new Exception('No se pudo conectar al Memcached: ' . $MemCachedObj->getResultMessage() . '.');
}
$MemCachedObj->setOption(Memcached::OPT_COMPRESSION, false);
$MemCachedObj->setOption(Memcached::OPT_BINARY_PROTOCOL, false);
$MemCachedObj->setOption(Memcached::OPT_CONNECT_TIMEOUT, 10000);
}
return $MemCachedObj;
}
示例8: all
/**
* @param array
* @throws RunTimeException
* @return array
*/
public function all(array $ids)
{
$this->keys = array();
$this->keys = preg_filter('/^/', $this->table . '_', $ids);
$data = $this->Memcached->getMulti($this->keys);
if ($data === false) {
$msg = $this->Memcached->getResultMessage();
$code = $this->Memcached->getResultCode();
throw new \RunTimeException("Memcached Error (all): " . $msg . "(" . $code . ")");
}
$result = array();
foreach ($data as $key => $val) {
$result[str_replace($this->table . '_', '', $key)] = json_decode(gzuncompress($val), true);
}
return $result;
}
示例9: get
/**
* Retrieves data from the cache identified by the specified key
*
* @param string $key The key.
*
* @return mixed
*
* @throws \YapepBase\Exception\StorageException On error.
*/
public function get($key)
{
$debugger = Application::getInstance()->getDiContainer()->getDebugger();
$startTime = microtime(true);
$result = $this->memcache->get($this->makeKey($key));
if (false === $result) {
$code = $this->memcache->getResultCode();
if (\Memcached::RES_NOTFOUND !== $code && \Memcached::RES_SUCCESS !== $code) {
throw new StorageException('Unable to get value in memcache. Error: ' . $this->memcache->getResultMessage(), $this->memcache->getResultCode());
}
}
// If we have a debugger, we have to log the request
if (!$this->debuggerDisabled && $debugger !== false) {
$debugger->addItem(new StorageItem('memcached', 'memcached.' . $this->currentConfigurationName, StorageItem::METHOD_GET . ' ' . $key, $result, microtime(true) - $startTime));
}
return $result;
}
示例10: storeValuesImpl
protected function storeValuesImpl(array $values, $expirationTime) {
$errorCacheEntryNames = NULL;
$adjustedExpirationTime = $expirationTime;
if (!isset($adjustedExpirationTime)) {
$adjustedExpirationTime = 0;
}
$storableValues = $deletableCacheEntryNames = NULL;
foreach ($values as $cacheEntryName => $value) {
if (isset($value)) {
$storableValues[$cacheEntryName] = $value;
}
else {
$deletableCacheEntryNames[] = $cacheEntryName;
}
}
if (isset($deletableCacheEntryNames)) {
foreach ($deletableCacheEntryNames as $deletableCacheEntryName) {
$result = $this->memcached->delete($deletableCacheEntryName);
if (($result === FALSE) && ($this->memcached->getResultCode() != Memcached::RES_NOTFOUND)) {
$errorCacheEntryNames[] = $deletableCacheEntryName;
LogHelper::log_error(t(
'[@cacheType] Internal error during value deletion: @message',
array('@cacheType' => self::CACHE__TYPE, '@message' => $this->memcached->getResultMessage())));
}
}
}
if (isset($storableValues)) {
$result = $this->memcached->setMulti($storableValues, $adjustedExpirationTime);
if ($result === FALSE) {
LogHelper::log_error(t(
'[@cacheType] Internal error during value storing: @message',
array('@cacheType' => self::CACHE__TYPE, '@message' => $this->memcached->getResultMessage())));
ArrayHelper::appendValue($errorCacheEntryNames, array_keys($storableValues));
}
}
return $errorCacheEntryNames;
}
示例11: 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();
}
示例12: getError
/**
* @return string
*/
public function getError()
{
return $this->memcached->getResultMessage();
}
示例13: error
/**
* 错误处理
* @param $op
* @param $key
* @throws \Simple\Model\Exception\DbException
*/
private function error($op, $key)
{
throw new DbException($op . '操作' . $key . '出错,错误码为:' . $this->dbh->getResultCode() . ',具体信息为:' . $this->dbh->getResultMessage());
}
示例14: testGetMissing
public function testGetMissing()
{
$request = new MemcacheGetRequest();
$request->addKey("key");
$response = new MemcacheGetResponse();
$this->apiProxyMock->expectCall('memcache', 'Get', $request, $response);
$memcached = new Memcached();
$this->assertFalse($memcached->get("key"));
$this->assertEquals($memcached->getResultCode(), Memcached::RES_NOTFOUND);
$this->assertEquals($memcached->getResultMessage(), 'NOT FOUND');
$this->apiProxyMock->verify();
}
示例15: resultMessage
/**
* {@inheritdoc}
*/
public function resultMessage()
{
return $this->memcache->getResultMessage();
}