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


PHP Redis::hKeys方法代码示例

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


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

示例1: isRunningSchedulerWorker

 /**
  * Check if the Scheduler Worker is already running
  *
  * @return boolean        True if the scheduler worker is already running
  */
 public function isRunningSchedulerWorker()
 {
     $pids = $this->redis->hKeys(self::$workerKey);
     $schedulerPid = $this->redis->get(self::$schedulerWorkerKey);
     if ($schedulerPid !== false && is_array($pids)) {
         if (in_array($schedulerPid, $pids)) {
             return true;
         }
         // Pid is outdated, remove it
         $this->unregisterSchedulerWorker();
         return false;
     }
     return false;
 }
开发者ID:nosun,项目名称:php-resque-cronjob,代码行数:19,代码来源:ResqueStatus.php

示例2: getKeyInfoObject

 /**
  * @param string $key
  *
  * @return ProvidesKeyInformation
  */
 public function getKeyInfoObject($key)
 {
     list($type, $ttl) = $this->redis->multi()->type($key)->pttl($key)->exec();
     if ($type == \Redis::REDIS_HASH) {
         $subItems = $this->redis->hKeys($key);
     } else {
         $subItems = [];
     }
     return new KeyInfo($key, $type, $ttl, $subItems);
 }
开发者ID:hollodotme,项目名称:readis,代码行数:15,代码来源:ServerManager.php

示例3: testHashes

 public function testHashes()
 {
     $this->redis->delete('h', 'key');
     $this->assertTrue(0 === $this->redis->hLen('h'));
     $this->assertTrue(TRUE === $this->redis->hSet('h', 'a', 'a-value'));
     $this->assertTrue(1 === $this->redis->hLen('h'));
     $this->assertTrue(TRUE === $this->redis->hSet('h', 'b', 'b-value'));
     $this->assertTrue(2 === $this->redis->hLen('h'));
     $this->assertTrue('a-value' === $this->redis->hGet('h', 'a'));
     // simple get
     $this->assertTrue('b-value' === $this->redis->hGet('h', 'b'));
     // simple get
     $this->assertTrue(FALSE === $this->redis->hSet('h', 'a', 'another-value'));
     // replacement
     $this->assertTrue('another-value' === $this->redis->hGet('h', 'a'));
     // get the new value
     $this->assertTrue('b-value' === $this->redis->hGet('h', 'b'));
     // simple get
     $this->assertTrue(FALSE === $this->redis->hGet('h', 'c'));
     // unknown hash member
     $this->assertTrue(FALSE === $this->redis->hGet('key', 'c'));
     // unknownkey
     // hDel
     $this->assertTrue(TRUE === $this->redis->hDel('h', 'a'));
     // TRUE on success
     $this->assertTrue(FALSE === $this->redis->hDel('h', 'a'));
     // FALSE on failure
     $this->redis->delete('h');
     $this->redis->hSet('h', 'x', 'a');
     $this->redis->hSet('h', 'y', 'b');
     // keys
     $keys = $this->redis->hKeys('h');
     $this->assertTrue($keys === array('x', 'y') || $keys === array('y', 'x'));
     // values
     $values = $this->redis->hVals('h');
     $this->assertTrue($values === array('a', 'b') || $values === array('b', 'a'));
     // keys + values
     $all = $this->redis->hGetAll('h');
     $this->assertTrue($all === array('x' => 'a', 'y' => 'b') || $all === array('y' => 'b', 'x' => 'a'));
     // hExists
     $this->assertTrue(TRUE === $this->redis->hExists('h', 'x'));
     $this->assertTrue(TRUE === $this->redis->hExists('h', 'y'));
     $this->assertTrue(FALSE === $this->redis->hExists('h', 'w'));
     $this->redis->delete('h');
     $this->assertTrue(FALSE === $this->redis->hExists('h', 'x'));
     // hIncrBy
     /*
     $this->redis->delete('h');
     $this->assertTrue(2.5 === $this->redis->hIncrBy('h', 2.5, 'x'));
     $this->assertTrue(3.5 === $this->redis->hIncrBy('h', 1, 'x'));
     
     $this->redis->hSet('h', 'y', 'not-a-number');
     $this->assertTrue(FALSE === $this->redis->hIncrBy('h', 1, 'y'));
     */
 }
开发者ID:korsunivan,项目名称:phpredis,代码行数:55,代码来源:TestRedis.php

示例4: testDifferentTypeSortedSet

 public function testDifferentTypeSortedSet()
 {
     $key = '{hash}sortedset';
     $dkey = '{hash}' . __FUNCTION__;
     $this->redis->del($key);
     $this->assertEquals(1, $this->redis->zAdd($key, 0, 'value'));
     // string I/F
     $this->assertEquals(FALSE, $this->redis->get($key));
     $this->assertEquals(FALSE, $this->redis->getset($key, 'value2'));
     $this->assertEquals(FALSE, $this->redis->append($key, 'append'));
     $this->assertEquals(FALSE, $this->redis->getRange($key, 0, 8));
     $this->assertEquals(array(FALSE), $this->redis->mget(array($key)));
     $this->assertEquals(FALSE, $this->redis->incr($key));
     $this->assertEquals(FALSE, $this->redis->incrBy($key, 1));
     $this->assertEquals(FALSE, $this->redis->decr($key));
     $this->assertEquals(FALSE, $this->redis->decrBy($key, 1));
     // lists I/F
     $this->assertEquals(FALSE, $this->redis->rPush($key, 'lvalue'));
     $this->assertEquals(FALSE, $this->redis->lPush($key, 'lvalue'));
     $this->assertEquals(FALSE, $this->redis->lLen($key));
     $this->assertEquals(FALSE, $this->redis->lPop($key));
     $this->assertEquals(FALSE, $this->redis->lrange($key, 0, -1));
     $this->assertEquals(FALSE, $this->redis->lTrim($key, 0, 1));
     $this->assertEquals(FALSE, $this->redis->lGet($key, 0));
     $this->assertEquals(FALSE, $this->redis->lSet($key, 0, "newValue"));
     $this->assertEquals(FALSE, $this->redis->lrem($key, 'lvalue', 1));
     $this->assertEquals(FALSE, $this->redis->lPop($key));
     $this->assertEquals(FALSE, $this->redis->rPop($key));
     $this->assertEquals(FALSE, $this->redis->rPoplPush($key, $dkey . 'lkey1'));
     // sets I/F
     $this->assertEquals(FALSE, $this->redis->sAdd($key, 'sValue1'));
     $this->assertEquals(FALSE, $this->redis->srem($key, 'sValue1'));
     $this->assertEquals(FALSE, $this->redis->sPop($key));
     $this->assertEquals(FALSE, $this->redis->sMove($key, $dkey . 'skey1', 'sValue1'));
     $this->assertEquals(FALSE, $this->redis->scard($key));
     $this->assertEquals(FALSE, $this->redis->sismember($key, 'sValue1'));
     $this->assertEquals(FALSE, $this->redis->sInter($key, $dkey . 'skey2'));
     $this->assertEquals(FALSE, $this->redis->sUnion($key, $dkey . 'skey4'));
     $this->assertEquals(FALSE, $this->redis->sDiff($key, $dkey . 'skey7'));
     $this->assertEquals(FALSE, $this->redis->sMembers($key));
     $this->assertEquals(FALSE, $this->redis->sRandMember($key));
     // hash I/F
     $this->assertEquals(FALSE, $this->redis->hSet($key, 'key1', 'value1'));
     $this->assertEquals(FALSE, $this->redis->hGet($key, 'key1'));
     $this->assertEquals(FALSE, $this->redis->hMGet($key, array('key1')));
     $this->assertEquals(FALSE, $this->redis->hMSet($key, array('key1' => 'value1')));
     $this->assertEquals(FALSE, $this->redis->hIncrBy($key, 'key2', 1));
     $this->assertEquals(FALSE, $this->redis->hExists($key, 'key2'));
     $this->assertEquals(FALSE, $this->redis->hDel($key, 'key2'));
     $this->assertEquals(FALSE, $this->redis->hLen($key));
     $this->assertEquals(FALSE, $this->redis->hKeys($key));
     $this->assertEquals(FALSE, $this->redis->hVals($key));
     $this->assertEquals(FALSE, $this->redis->hGetAll($key));
 }
开发者ID:Jerry-Shaw,项目名称:phpredis,代码行数:54,代码来源:RedisTest.php

示例5: Redis

<?php

$redis_server = 'localhost:6379';
try {
    $redis = new Redis();
    $redis->connect($redis_server);
    $locations = $redis->hKeys('locations');
    $services = $redis->hKeys('services');
    $checks = $redis->hKeys('checks');
    sort($locations);
    sort($services);
    sort($checks);
    $tbl = "<table><tr><th></th>";
    foreach ($locations as $location) {
        $tbl .= "<th>" . $location . "</th>";
    }
    $tbl .= "</tr>";
    $date = new DateTime();
    $timestamp = $date->getTimestamp();
    $rowscount = count($checks);
    foreach ($services as $service) {
        $nonexist_locations = array();
        $service_row = "<tr><td rowspan=%d style='border-top-style: solid;'>" . $service . "</td>";
        $opentag = 0;
        $closetag = 1;
        foreach ($checks as $check) {
            $add_check = 1;
            foreach ($locations as $location) {
                $value = $redis->hGet($location . ':' . $service, $check);
                $prev_value = $redis->hGet($location . ':' . $service, $check . ':prev');
                $is_supported = False;
开发者ID:Zaynullin,项目名称:sensors,代码行数:31,代码来源:sensors.php

示例6: testHashes

 public function testHashes()
 {
     $this->redis->delete('h', 'key');
     $this->assertTrue(0 === $this->redis->hLen('h'));
     $this->assertTrue(1 === $this->redis->hSet('h', 'a', 'a-value'));
     $this->assertTrue(1 === $this->redis->hLen('h'));
     $this->assertTrue(1 === $this->redis->hSet('h', 'b', 'b-value'));
     $this->assertTrue(2 === $this->redis->hLen('h'));
     $this->assertTrue('a-value' === $this->redis->hGet('h', 'a'));
     // simple get
     $this->assertTrue('b-value' === $this->redis->hGet('h', 'b'));
     // simple get
     $this->assertTrue(0 === $this->redis->hSet('h', 'a', 'another-value'));
     // replacement
     $this->assertTrue('another-value' === $this->redis->hGet('h', 'a'));
     // get the new value
     $this->assertTrue('b-value' === $this->redis->hGet('h', 'b'));
     // simple get
     $this->assertTrue(FALSE === $this->redis->hGet('h', 'c'));
     // unknown hash member
     $this->assertTrue(FALSE === $this->redis->hGet('key', 'c'));
     // unknownkey
     // hDel
     $this->assertTrue(1 === $this->redis->hDel('h', 'a'));
     // 1 on success
     $this->assertTrue(0 === $this->redis->hDel('h', 'a'));
     // 0 on failure
     $this->redis->delete('h');
     $this->redis->hSet('h', 'x', 'a');
     $this->redis->hSet('h', 'y', 'b');
     $this->assertTrue(2 === $this->redis->hDel('h', 'x', 'y'));
     // variadic
     // hsetnx
     $this->redis->delete('h');
     $this->assertTrue(TRUE === $this->redis->hSetNx('h', 'x', 'a'));
     $this->assertTrue(TRUE === $this->redis->hSetNx('h', 'y', 'b'));
     $this->assertTrue(FALSE === $this->redis->hSetNx('h', 'x', '?'));
     $this->assertTrue(FALSE === $this->redis->hSetNx('h', 'y', '?'));
     $this->assertTrue('a' === $this->redis->hGet('h', 'x'));
     $this->assertTrue('b' === $this->redis->hGet('h', 'y'));
     // keys
     $keys = $this->redis->hKeys('h');
     $this->assertTrue($keys === array('x', 'y') || $keys === array('y', 'x'));
     // values
     $values = $this->redis->hVals('h');
     $this->assertTrue($values === array('a', 'b') || $values === array('b', 'a'));
     // keys + values
     $all = $this->redis->hGetAll('h');
     $this->assertTrue($all === array('x' => 'a', 'y' => 'b') || $all === array('y' => 'b', 'x' => 'a'));
     // hExists
     $this->assertTrue(TRUE === $this->redis->hExists('h', 'x'));
     $this->assertTrue(TRUE === $this->redis->hExists('h', 'y'));
     $this->assertTrue(FALSE === $this->redis->hExists('h', 'w'));
     $this->redis->delete('h');
     $this->assertTrue(FALSE === $this->redis->hExists('h', 'x'));
     // hIncrBy
     $this->redis->delete('h');
     $this->assertTrue(2 === $this->redis->hIncrBy('h', 'x', 2));
     $this->assertTrue(3 === $this->redis->hIncrBy('h', 'x', 1));
     $this->assertTrue(2 === $this->redis->hIncrBy('h', 'x', -1));
     $this->assertTrue(FALSE === $this->redis->hIncrBy('h', 'x', "not-a-number"));
     $this->assertTrue("2" === $this->redis->hGet('h', 'x'));
     $this->redis->hSet('h', 'y', 'not-a-number');
     $this->assertTrue(FALSE === $this->redis->hIncrBy('h', 'y', 1));
     // hIncrByFloat
     $this->redis->delete('h');
     $this->assertTrue(1.5 === $this->redis->hIncrByFloat('h', 'x', 1.5));
     $this->assertTrue(3.0 === $this->redis->hincrByFloat('h', 'x', 1.5));
     $this->assertTrue(1.5 === $this->redis->hincrByFloat('h', 'x', -1.5));
     $this->redis->hset('h', 'y', 'not-a-number');
     $this->assertTrue(FALSE === $this->redis->hIncrByFloat('h', 'y', 1.5));
     // hmset
     $this->redis->delete('h');
     $this->assertTrue(TRUE === $this->redis->hMset('h', array('x' => 123, 'y' => 456, 'z' => 'abc')));
     $this->assertTrue('123' === $this->redis->hGet('h', 'x'));
     $this->assertTrue('456' === $this->redis->hGet('h', 'y'));
     $this->assertTrue('abc' === $this->redis->hGet('h', 'z'));
     $this->assertTrue(FALSE === $this->redis->hGet('h', 't'));
     // hmget
     $this->assertTrue(array('x' => '123', 'y' => '456') === $this->redis->hMget('h', array('x', 'y')));
     $this->assertTrue(array('z' => 'abc') === $this->redis->hMget('h', array('z')));
     $this->assertTrue(array('x' => '123', 't' => FALSE, 'y' => '456') === $this->redis->hMget('h', array('x', 't', 'y')));
     $this->assertFalse(array(123 => 'x') === $this->redis->hMget('h', array(123)));
     $this->assertTrue(array(123 => FALSE) === $this->redis->hMget('h', array(123)));
     // hmget/hmset with numeric fields
     $this->redis->del('h');
     $this->assertTrue(TRUE === $this->redis->hMset('h', array(123 => 'x', 'y' => 456)));
     $this->assertTrue('x' === $this->redis->hGet('h', 123));
     $this->assertTrue('x' === $this->redis->hGet('h', '123'));
     $this->assertTrue('456' === $this->redis->hGet('h', 'y'));
     $this->assertTrue(array(123 => 'x', 'y' => '456') === $this->redis->hMget('h', array('123', 'y')));
     // check non-string types.
     $this->redis->delete('h1');
     $this->assertTrue(TRUE === $this->redis->hMSet('h1', array('x' => 0, 'y' => array(), 'z' => new stdclass(), 't' => NULL)));
     $h1 = $this->redis->hGetAll('h1');
     $this->assertTrue('0' === $h1['x']);
     $this->assertTrue('Array' === $h1['y']);
     $this->assertTrue('Object' === $h1['z']);
     $this->assertTrue('' === $h1['t']);
 }
开发者ID:0,项目名称:phpredis,代码行数:100,代码来源:TestRedis.php

示例7: testHashes

 public function testHashes()
 {
     $this->redis->delete('h', 'key');
     $this->assertTrue(0 === $this->redis->hLen('h'));
     $this->assertTrue(TRUE === $this->redis->hSet('h', 'a', 'a-value'));
     $this->assertTrue(1 === $this->redis->hLen('h'));
     $this->assertTrue(TRUE === $this->redis->hSet('h', 'b', 'b-value'));
     $this->assertTrue(2 === $this->redis->hLen('h'));
     $this->assertTrue('a-value' === $this->redis->hGet('h', 'a'));
     // simple get
     $this->assertTrue('b-value' === $this->redis->hGet('h', 'b'));
     // simple get
     $this->assertTrue(FALSE === $this->redis->hSet('h', 'a', 'another-value'));
     // replacement
     $this->assertTrue('another-value' === $this->redis->hGet('h', 'a'));
     // get the new value
     $this->assertTrue('b-value' === $this->redis->hGet('h', 'b'));
     // simple get
     $this->assertTrue(FALSE === $this->redis->hGet('h', 'c'));
     // unknown hash member
     $this->assertTrue(FALSE === $this->redis->hGet('key', 'c'));
     // unknownkey
     // hDel
     $this->assertTrue(TRUE === $this->redis->hDel('h', 'a'));
     // TRUE on success
     $this->assertTrue(FALSE === $this->redis->hDel('h', 'a'));
     // FALSE on failure
     $this->redis->delete('h');
     $this->redis->hSet('h', 'x', 'a');
     $this->redis->hSet('h', 'y', 'b');
     // keys
     $keys = $this->redis->hKeys('h');
     $this->assertTrue($keys === array('x', 'y') || $keys === array('y', 'x'));
     // values
     $values = $this->redis->hVals('h');
     $this->assertTrue($values === array('a', 'b') || $values === array('b', 'a'));
     // keys + values
     $all = $this->redis->hGetAll('h');
     $this->assertTrue($all === array('x' => 'a', 'y' => 'b') || $all === array('y' => 'b', 'x' => 'a'));
     // hExists
     $this->assertTrue(TRUE === $this->redis->hExists('h', 'x'));
     $this->assertTrue(TRUE === $this->redis->hExists('h', 'y'));
     $this->assertTrue(FALSE === $this->redis->hExists('h', 'w'));
     $this->redis->delete('h');
     $this->assertTrue(FALSE === $this->redis->hExists('h', 'x'));
     // hIncrBy
     $this->redis->delete('h');
     $this->assertTrue(25 === $this->redis->hIncrBy('h', 'x', 25));
     $this->assertTrue(35 === $this->redis->hIncrBy('h', 'x', 10));
     $this->redis->hSet('h', 'y', 'not-a-number');
     $this->assertTrue(FALSE === $this->redis->hIncrBy('h', 'y', 1));
     $this->redis->delete('h1');
     //hMGet, hMSet
     $this->redis->hset("h1", "field1", "value1");
     $this->redis->hset("h1", "field2", "value2");
     $this->assertTrue(array('field1' => 'value1', 'field2' => 'value2') === $this->redis->hGetAll('h1'));
     $this->assertTrue(array('field1' => 'value1', 'field2' => 'value2') === $this->redis->hMGet('h1', array('field1', 'field2')));
     $this->assertTrue(array('field1' => 'value1') === $this->redis->hMGet('h1', array('field1')));
     $this->assertTrue(FALSE === $this->redis->hMGet('h1', array()));
     $this->assertTrue(TRUE === $this->redis->hMSet('h1', array('field3' => 'value3')));
     $this->assertTrue(array('field1' => 'value1', 'field2' => 'value2', 'field3' => 'value3') === $this->redis->hGetAll('h1'));
     $this->assertTrue(TRUE === $this->redis->hMSet('h1', array('field3' => 'value4')));
     $this->assertTrue(array('field1' => 'value1', 'field2' => 'value2', 'field3' => 'value4') === $this->redis->hGetAll('h1'));
     $this->assertTrue(TRUE === $this->redis->hMSet('h1', array('x' => 0, 'y' => array(), 'z' => new stdclass())));
     $h1 = $this->redis->hGetAll('h1');
     $this->assertTrue('0' === $h1['x']);
     $this->assertTrue('Array' === $h1['y']);
     $this->assertTrue('Object' === $h1['z']);
 }
开发者ID:virtulis,项目名称:phpredis,代码行数:69,代码来源:TestRedis.php

示例8: find_all

 /**
  * Finds all of the keys being used by this cache store instance.
  *
  * @return array of all keys in the hash as a numbered array.
  */
 public function find_all()
 {
     return $this->redis->hKeys($this->hash);
 }
开发者ID:lucaboesch,项目名称:moodle,代码行数:9,代码来源:lib.php

示例9: hashGet

 /**
  * 获取hash表的数据
  * @param $hash string 哈希表名
  * @param $key mixed 表中要存储的key名 默认为null 返回所有key->value
  * @param $type int 要获取的数据类型 0:返回所有key 1:返回所有value 2:返回所有key->value
  */
 public static function hashGet($hash, $key = array(), $type = 0)
 {
     $redis = new \Redis();
     $redis->connect(self::_HOST, self::_PORT);
     $return = null;
     if ($key) {
         if (is_array($key) && !empty($key)) {
             $return = $redis->hMGet($hash, $key);
         } else {
             $return = $redis->hGet($hash, $key);
         }
     } else {
         switch ($type) {
             case 0:
                 $return = $redis->hKeys($hash);
                 break;
             case 1:
                 $return = $redis->hVals($hash);
                 break;
             case 2:
                 $return = $redis->hGetAll($hash);
                 break;
             default:
                 $return = false;
                 break;
         }
     }
     $redis->close();
     $redis = null;
     return $return;
 }
开发者ID:skyshow,项目名称:ticket,代码行数:37,代码来源:MyRedis.class.php


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