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


PHP Redis::getLastError方法代码示例

本文整理汇总了PHP中Redis::getLastError方法的典型用法代码示例。如果您正苦于以下问题:PHP Redis::getLastError方法的具体用法?PHP Redis::getLastError怎么用?PHP Redis::getLastError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Redis的用法示例。


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

示例1: connect

 private function connect($server)
 {
     $redis = new Redis();
     if ($redis->connect($server['host'], $server['port'], $server['timeout']) == false) {
         die($redis->getLastError());
     }
     if (!empty($server['auth'])) {
         $auth = $server['auth'];
         if ($redis->auth($auth['user'] . ":" . $auth['password']) == false) {
             die($redis->getLastError());
         }
     }
     return $redis;
 }
开发者ID:homekuanyi,项目名称:windphp,代码行数:14,代码来源:RedisCache.class.php

示例2: run

 public function run($command, $args)
 {
     if (empty($this->sha)) {
         $this->reload();
     }
     $luaArgs = [$command, microtime(true)];
     $argArray = array_merge($luaArgs, $args);
     $result = $this->redisCli->evalSha($this->sha, $argArray);
     $error = $this->redisCli->getLastError();
     if ($error) {
         $this->handleError($error);
         return null;
     }
     return $result;
 }
开发者ID:contatta,项目名称:qless-php,代码行数:15,代码来源:Lua.php

示例3: get

 /**
  * Get cache element
  *
  * This method will throw only logical exceptions.
  * In case of failures, it will return a null value.
  * In case of cache not found, it will return a null value.
  *
  * @param   string  $name    Name for cache element
  *
  * @return  mixed
  * @throws \Comodojo\Exception\CacheException
  */
 public function get($name)
 {
     if (empty($name)) {
         throw new CacheException("Name of object cannot be empty");
     }
     if (!$this->isEnabled()) {
         return null;
     }
     $this->resetErrorState();
     try {
         $namespace = $this->getNamespaceKey();
         if ($namespace === false) {
             $return = false;
         } else {
             $shadowName = $namespace . "-" . md5($name);
             $return = $this->instance->get($shadowName);
             if ($return === false) {
                 $this->raiseError("Error reading cache (PhpRedis), exiting gracefully", array($this->instance->getLastError()));
                 $this->setErrorState();
             }
         }
     } catch (CacheException $ce) {
         throw $ce;
     } catch (RedisException $re) {
         $this->raiseError("Server unreachable (PhpRedis), exiting gracefully", array("RESULTCODE" => $re->getCode(), "RESULTMESSAGE" => $re->getMessage()));
         $this->setErrorState();
         return null;
     }
     return $return === false ? null : unserialize($return);
 }
开发者ID:comodojo,项目名称:cache,代码行数:42,代码来源:PhpRedisCache.php

示例4: testGetLastError

 public function testGetLastError()
 {
     // We shouldn't have any errors now
     $this->assertTrue($this->redis->getLastError() === NULL);
     // Throw some invalid lua at redis
     $this->redis->eval("not-a-lua-script");
     // Now we should have an error
     $this->assertTrue(strlen($this->redis->getLastError()) > 0);
 }
开发者ID:neatstudio,项目名称:phpredis,代码行数:9,代码来源:TestRedis.php

示例5: testGetLastError

 public function testGetLastError()
 {
     // We shouldn't have any errors now
     $this->assertTrue($this->redis->getLastError() === NULL);
     // test getLastError with a regular command
     $this->redis->set('x', 'a');
     $this->assertFalse($this->redis->incr('x'));
     $incrError = $this->redis->getLastError();
     $this->assertTrue(strlen($incrError) > 0);
     // clear error
     $this->redis->clearLastError();
     $this->assertTrue($this->redis->getLastError() === NULL);
 }
开发者ID:Jerry-Shaw,项目名称:phpredis,代码行数:13,代码来源:RedisTest.php

示例6: mget

 protected function mget()
 {
     $this->db->watch([$this->count]);
     $error = $this->db->getLastError();
     if ($error) {
         return $error;
     }
     $replies = $this->db->mGet([$this->count, $this->limit, $this->reset]);
     $error = $this->db->getLastError();
     if ($error) {
         return $error;
     }
     if (!$replies[0] && $replies[0] !== '0') {
         return $this->create();
     }
     return $this->decr($replies);
 }
开发者ID:leilt331,项目名称:rest_api,代码行数:17,代码来源:RateLimiter.php

示例7: testGetLastError

 public function testGetLastError()
 {
     // We shouldn't have any errors now
     $this->assertTrue($this->redis->getLastError() === NULL);
     // Throw some invalid lua at redis
     $this->redis->eval("not-a-lua-script");
     // Now we should have an error
     $evalError = $this->redis->getLastError();
     $this->assertTrue(strlen($evalError) > 0);
     // test getLastError with a regular command
     $this->redis->set('x', 'a');
     $this->assertFalse($this->redis->incr('x'));
     $incrError = $this->redis->getLastError();
     $this->assertTrue($incrError !== $evalError);
     // error has changed
     $this->assertTrue(strlen($incrError) > 0);
     // clear error
     $this->redis->clearLastError();
     $this->assertTrue($this->redis->getLastError() === NULL);
 }
开发者ID:stonegithubs,项目名称:phpredis,代码行数:20,代码来源:TestRedis.php

示例8: __call


//.........这里部分代码省略.........
                 $args = array($args[0], array_merge($cKeys, $cArgs), count($cKeys));
                 break;
             case 'subscribe':
             case 'psubscribe':
                 break;
             case 'scan':
             case 'sscan':
             case 'hscan':
             case 'zscan':
                 // allow phpredis to see the caller's reference
                 //$param_ref =& $args[0];
                 break;
             default:
                 // Flatten arguments
                 $args = self::_flattenArguments($args);
         }
         try {
             // Proxy pipeline mode to the phpredis library
             if ($name == 'pipeline' || $name == 'multi') {
                 if ($this->isMulti) {
                     return $this;
                 } else {
                     $this->isMulti = TRUE;
                     $this->redisMulti = call_user_func_array(array($this->redis, $name), $args);
                 }
             } else {
                 if ($name == 'exec' || $name == 'discard') {
                     $this->isMulti = FALSE;
                     $response = $this->redisMulti->{$name}();
                     $this->redisMulti = NULL;
                     #echo "> $name : ".substr(print_r($response, TRUE),0,100)."\n";
                     return $response;
                 }
             }
             // Use aliases to be compatible with phpredis wrapper
             if (isset($this->wrapperMethods[$name])) {
                 $name = $this->wrapperMethods[$name];
             }
             // Multi and pipeline return self for chaining
             if ($this->isMulti) {
                 call_user_func_array(array($this->redisMulti, $name), $args);
                 return $this;
             }
             // Send request, retry one time when using persistent connections on the first request only
             $this->requests++;
             try {
                 $response = call_user_func_array(array($this->redis, $name), $args);
             } catch (RedisException $e) {
                 if ($this->persistent && $this->requests == 1 && $e->getMessage() == 'read error on connection') {
                     $this->connected = FALSE;
                     $this->connect();
                     $response = call_user_func_array(array($this->redis, $name), $args);
                 } else {
                     throw $e;
                 }
             }
         } catch (RedisException $e) {
             $code = 0;
             if (!($result = $this->redis->IsConnected())) {
                 $this->connected = FALSE;
                 $code = CredisException::CODE_DISCONNECTED;
             }
             throw new CredisException($e->getMessage(), $code, $e);
         }
         #echo "> $name : ".substr(print_r($response, TRUE),0,100)."\n";
         // change return values where it is too difficult to minim in standalone mode
         switch ($name) {
             case 'hmget':
                 $response = array_values($response);
                 break;
             case 'type':
                 $typeMap = array(self::TYPE_NONE, self::TYPE_STRING, self::TYPE_SET, self::TYPE_LIST, self::TYPE_ZSET, self::TYPE_HASH);
                 $response = $typeMap[$response];
                 break;
                 // Handle scripting errors
             // Handle scripting errors
             case 'eval':
             case 'evalsha':
             case 'script':
                 $error = $this->redis->getLastError();
                 $this->redis->clearLastError();
                 if ($error && substr($error, 0, 8) == 'NOSCRIPT') {
                     $response = NULL;
                 } else {
                     if ($error) {
                         throw new CredisException($error);
                     }
                 }
                 break;
             default:
                 $error = $this->redis->getLastError();
                 $this->redis->clearLastError();
                 if ($error) {
                     throw new CredisException($error);
                 }
                 break;
         }
     }
     return $response;
 }
开发者ID:cboelter,项目名称:credis,代码行数:101,代码来源:Client.php

示例9: getLastError

 /**
  * @return string|NULL
  * */
 public function getLastError()
 {
     return parent::getLastError();
 }
开发者ID:sallyx,项目名称:redis-php-stream-wrapper,代码行数:7,代码来源:Redis.php

示例10: __call


//.........这里部分代码省略.........
             case 'psubscribe':
                 break;
             default:
                 // Flatten arguments
                 $argsFlat = null;
                 foreach ($args as $index => $arg) {
                     if (is_array($arg)) {
                         if ($argsFlat === null) {
                             $argsFlat = array_slice($args, 0, $index);
                         }
                         $argsFlat = array_merge($argsFlat, $arg);
                     } elseif ($argsFlat !== null) {
                         $argsFlat[] = $arg;
                     }
                 }
                 if ($argsFlat !== null) {
                     $args = $argsFlat;
                     $argsFlat = null;
                 }
         }
         try {
             // Proxy pipeline mode to the phpredis library
             if ($name == 'pipeline' || $name == 'multi') {
                 if ($this->isMulti) {
                     return $this;
                 } else {
                     $this->isMulti = true;
                     $this->redisMulti = call_user_func_array(array($this->redis, $name), $args);
                 }
             } elseif ($name == 'exec' || $name == 'discard') {
                 $this->isMulti = false;
                 $response = $this->redisMulti->{$name}();
                 $this->redisMulti = null;
                 #echo "> $name : ".substr(print_r($response, TRUE),0,100)."\n";
                 return $response;
             }
             // Use aliases to be compatible with phpredis wrapper
             if (isset($this->wrapperMethods[$name])) {
                 $name = $this->wrapperMethods[$name];
             }
             // Multi and pipeline return self for chaining
             if ($this->isMulti) {
                 call_user_func_array(array($this->redisMulti, $name), $args);
                 return $this;
             }
             // Send request, retry one time when using persistent connections on the first request only
             $this->requests++;
             try {
                 $response = call_user_func_array(array($this->redis, $name), $args);
             } catch (RedisException $e) {
                 if ($this->persistent && $this->requests == 1 && $e->getMessage() == 'read error on connection') {
                     $this->connected = false;
                     $this->connect();
                     $response = call_user_func_array(array($this->redis, $name), $args);
                 } else {
                     throw $e;
                 }
             }
         } catch (RedisException $e) {
             $code = 0;
             if (!($result = $this->redis->IsConnected())) {
                 $this->connected = false;
                 $code = CredisException::CODE_DISCONNECTED;
             }
             throw new CredisException($e->getMessage(), $code, $e);
         }
         #echo "> $name : ".substr(print_r($response, TRUE),0,100)."\n";
         // change return values where it is too difficult to minim in standalone mode
         switch ($name) {
             case 'hmget':
                 $response = array_values($response);
                 break;
             case 'type':
                 $typeMap = array(self::TYPE_NONE, self::TYPE_STRING, self::TYPE_SET, self::TYPE_LIST, self::TYPE_ZSET, self::TYPE_HASH);
                 $response = $typeMap[$response];
                 break;
                 // Handle scripting errors
             // Handle scripting errors
             case 'eval':
             case 'evalsha':
             case 'script':
                 $error = $this->redis->getLastError();
                 $this->redis->clearLastError();
                 if ($error && substr($error, 0, 8) == 'NOSCRIPT') {
                     $response = null;
                 } elseif ($error) {
                     throw new CredisException($error);
                 }
                 break;
             default:
                 $error = $this->redis->getLastError();
                 $this->redis->clearLastError();
                 if ($error) {
                     throw new CredisException($error);
                 }
                 break;
         }
     }
     return $response;
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:101,代码来源:Client.php

示例11: elseif

    $port = 6379;
} elseif (App == "product") {
    $host = "172.17.16.46";
    $port = 6379;
    $instanceid = "16fd0afe-7bfd-4f00-b546-5768a6b61995";
    $pwd = "gc7232275";
} elseif (App == "test") {
    $host = "172.17.11.5";
    $port = 6379;
} else {
    exit("未知环境");
}
$redis = new Redis();
//连接redis
if ($redis->connect($host, $port) == false) {
    die($redis->getLastError());
}
//鉴权
if (App == "product" && $redis->auth($instanceid . ":" . $pwd) == false) {
    die("鉴权验证失败!");
}
$pinyinArr = json_decode(file_get_contents("/data/cap/V3/gc.api/branches/dev/vendor/xz/composerlib/XzFunc/data/dict.php"));
foreach ($pinyinArr as $key => $value) {
    $checkArr = $redis->get("py:" . $key);
    if ($checkArr) {
        var_dump($checkArr);
        echo "\n";
        echo App . "环境已经初始化过了!";
        exit;
    }
    if ($redis->set("py:" . $key, $value) == false) {
开发者ID:tianyunchong,项目名称:php,代码行数:31,代码来源:redis.php

示例12: Redis

<?php

$redis = new Redis();
$redis->connect('127.0.0.1', 6300);
if (file_exists('./merge_data.sha')) {
    $evalSha = file_get_contents('./merge_data.sha');
}
if (empty($evalSha)) {
    $evalSha = $redis->script("load", file_get_contents('merge_data.lua'));
    file_put_contents('./merge_data.sha', $evalSha);
}
var_dump($redis->evalSha($evalSha), $redis->getLastError() ?: "No errors");
开发者ID:kirillv,项目名称:opentracker,代码行数:12,代码来源:merge_data.php

示例13: Redis

<?php

// vim: set expandtab cindent tabstop=4 shiftwidth=4 fdm=marker:
/**
 * @file     redisEvalShaTest.php
 * @version  1.0
 * @author   wade
 * @date     2014-12-01 22:56:38
 * @desc     redis集成lua脚本功能实现浏览历史功能
 */
$redis = new Redis();
$redis->connect('127.0.0.1', '6379');
// $redis->set('test', 'Hello World');
// echo $redis->get('test');
$luaScript = file_get_contents('./addItemToBrowsingHistory.lua');
$ret = $redis->eval($luaScript, array(4011, 'brand_browsing_10011', 1417582943, 'brand_expired_10011', 1417582943, 1417582943, 3, 1417482943));
var_export($ret);
$err = $redis->getLastError();
var_export($err);
开发者ID:sdgdsffdsfff,项目名称:historyBrowsing,代码行数:19,代码来源:addItemToBrowsingHistoryTest.php

示例14: testRedis

 private function testRedis(\Redis $redis, $method, $params, $keyToCleanUp, OutputInterface $output)
 {
     if ($keyToCleanUp) {
         $redis->delete($keyToCleanUp);
     }
     $result = call_user_func_array(array($redis, $method), $params);
     $paramsInline = implode(', ', $params);
     if ($result) {
         $output->writeln("Success for method {$method}({$paramsInline})");
     } else {
         $errorMessage = $redis->getLastError();
         $output->writeln("<error>Failure for method {$method}({$paramsInline}): {$errorMessage}</error>");
     }
     if ($keyToCleanUp) {
         $redis->delete($keyToCleanUp);
     }
 }
开发者ID:ruchitrami,项目名称:plugin-QueuedTracking,代码行数:17,代码来源:Test.php

示例15: assertResult

 /**
  * @param mixed $result
  *
  * @throws QueueException
  */
 protected function assertResult($result)
 {
     if (false === $result) {
         throw new QueueException($this, $this->redis->getLastError());
     }
 }
开发者ID:rybakit,项目名称:phive-queue,代码行数:11,代码来源:RedisQueue.php


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