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


PHP Redis::hDel方法代码示例

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


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

示例1: delete

 /**
  * delete var
  *
  * @param $key
  * @return bool
  */
 public function delete($key)
 {
     if ($this->redis->hDel($this->prefix, $key) > 0) {
         return true;
     }
     return false;
 }
开发者ID:huyanping,项目名称:simple-fork-php,代码行数:13,代码来源:RedisCache.php

示例2: finish

 /**
  * @inheritdoc
  */
 public function finish($messageId)
 {
     $this->checkClientConnection();
     $this->client->hDel("queue:{$this->name}:ids", $messageId);
     $this->client->hDel("queue:{$this->name}:releases", $messageId);
     return $this->client->lRem("queue:{$this->name}:processing", $messageId, 0) > 0;
 }
开发者ID:flowpack,项目名称:jobqueue-redis,代码行数:10,代码来源:RedisQueue.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: requeueOldWorkingMessages

 private function requeueOldWorkingMessages($type)
 {
     $messageIds = array_unique($this->redis->lRange($this->getMessageRunKey($type), 0, -1));
     foreach ($messageIds as $messageId) {
         $time = $this->redis->hGet($this->getMessageStartTimeKey($type), $messageId);
         if (!empty($time) && time() > $this->messageTimeout + (int) $time) {
             $this->redis->multi();
             $this->redis->rPush($this->getMessageQueueKey($type), $messageId);
             $this->redis->lRem($this->getMessageRunKey($type), $messageId, 1);
             $this->redis->hDel($this->getMessageStartTimeKey($type), $messageId);
             $this->redis->exec();
         }
     }
 }
开发者ID:parallel-php,项目名称:parallel-task,代码行数:14,代码来源:RedisQueue.php

示例6: getResult

 public function getResult($taskId)
 {
     $serializedTaskResult = $this->redis->hGet($this->getTaskResultKey(), $taskId);
     if (empty($serializedTaskResult)) {
         return null;
     }
     do {
         $resultReady = $this->redis->blPop($this->getTaskResultReadyKey($taskId), 1);
     } while (empty($resultReady));
     $serializedTaskResult = $this->redis->hGet($this->getTaskResultKey(), $taskId);
     $taskResult = unserialize($serializedTaskResult);
     $this->redis->hDel($this->getTaskResultKey(), $taskId);
     if ($taskResult instanceof TaskException) {
         throw $taskResult;
     }
     return $taskResult;
 }
开发者ID:drealecs,项目名称:thread-worker,代码行数:17,代码来源:RedisQueue.php

示例7: failed

 /**
  * Handle a job failure.
  *
  * @return void
  */
 public function failed()
 {
     // Called when the job is failing...
     $this->redis->hDel('jk_upvote:' . $this->sheet->getAttributeValue('song_id') . ':userLIST', $this->sheet->getAttributeValue('user_id'));
 }
开发者ID:RedrockTeam,项目名称:jukebox,代码行数:10,代码来源:UpVote.php

示例8: 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

示例9: removeWorker

 /**
  *
  */
 public function removeWorker($pid)
 {
     $this->redis->hDel(self::$workerKey, $pid);
 }
开发者ID:nosun,项目名称:php-resque-cronjob,代码行数:7,代码来源:ResqueStatus.php

示例10: Redis

}
$redis_ip = $_GET["redis_ip"];
$redis_port = $_GET["redis_port"];
$mysql_ip = $_GET["mysql_ip"];
$mysql_port = $_GET["mysql_port"];
$mysql_user = $_GET["mysql_user"];
$mysql_password = $_GET["mysql_password"];
$player_uin = $_GET["player_uin"];
$redis = new Redis();
if ($redis->connect($redis_ip, $redis_port, 10) == false) {
    echo "redis 连接失败";
} else {
    $result = $redis->hGetall("uin_mapping");
    if ($result) {
        foreach ($result as $key => $val) {
            if ($val == $player_uin) {
                $mysql_con = mysql_connect($mysql_ip . ":" . $mysql_port, $mysql_user, $mysql_password);
                if ($mysql_con && mysql_select_db("fgame", $mysql_con)) {
                    $redis->hDel("uin_mapping", $key);
                    $result = mysql_query("DELETE FROM uin_mapping where uin = '" . $player_uin . "'");
                    echo "openid : " . $key . " is deleted";
                    mysql_close($mysql_con);
                } else {
                    echo "mysql connect faild";
                }
                break;
            }
        }
    }
    $redis->close();
}
开发者ID:tofindme,项目名称:work_note,代码行数:31,代码来源:del_one_player_uin_submit.php

示例11: 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

示例12: delete

 /**
  * Delete the given key.
  *
  * @param string $key The key to delete.
  * @return bool True if the delete operation succeeds, false otherwise.
  */
 public function delete($key)
 {
     return $this->redis->hDel($this->hash, $key) > 0;
 }
开发者ID:lucaboesch,项目名称:moodle,代码行数:10,代码来源:lib.php

示例13: remove

 /**
  * {@inheritDoc}
  */
 public function remove($key)
 {
     $this->redis->hDel($this->cacheKey, $key);
     return true;
 }
开发者ID:Gtvar,项目名称:FivePercent-Cache,代码行数:8,代码来源:RedisCache.php

示例14: hashDel

 /**
  * 删除hash表中的key
  * @param $hash string 哈希表名
  * @param $key mixed 表中存储的key名
  */
 public static function hashDel($hash, $key)
 {
     $redis = new \Redis();
     $redis->connect(self::_HOST, self::_PORT);
     $return = null;
     $return = $redis->hDel($hash, $key);
     $redis->close();
     $redis = null;
     return $return;
 }
开发者ID:skyshow,项目名称:ticket,代码行数:15,代码来源:MyRedis.class.php


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