當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Redis::type方法代碼示例

本文整理匯總了PHP中Redis::type方法的典型用法代碼示例。如果您正苦於以下問題:PHP Redis::type方法的具體用法?PHP Redis::type怎麽用?PHP Redis::type使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Redis的用法示例。


在下文中一共展示了Redis::type方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: type

 /**
  * 返回該k的數據類型
  * @example string: Redis::REDIS_STRING sets: Redis::REDIS_SET list: Redis::REDIS_LIST zsets: Redis::REDIS_ZSET hashes: Redis::REDIS_HASH other: Redis::REDIS_NOT_FOUND
  * @return string sets|string|list|zsets|hashes|other
  */
 public function type()
 {
     try {
         $redisType = $this->rd->type($this->k);
     } catch (\RedisException $e) {
         if ($this->reconnRedis()) {
             $redisType = $this->rd->type($this->k);
         } else {
             $redisType = '';
         }
     }
     switch ($redisType) {
         case \Redis::REDIS_SET:
             return 'sets';
         case \Redis::REDIS_HASH:
             return 'hashes';
         case \Redis::REDIS_LIST:
             return 'list';
         case \Redis::REDIS_STRING:
             return 'string';
         case \Redis::REDIS_ZSET:
             return 'zsets';
         case \Redis::REDIS_NOT_FOUND:
         default:
             return 'other';
     }
 }
開發者ID:seepre,項目名稱:api.seepre.com,代碼行數:32,代碼來源:RedBaseModel.php

示例2: setSavesSetDataTypeForTagToIdentifiersSet

 /**
  * @test Implementation
  */
 public function setSavesSetDataTypeForTagToIdentifiersSet()
 {
     $this->setUpBackend();
     $this->setUpRedis();
     $identifier = 'identifier' . uniqid();
     $tag = 'tag';
     $this->backend->set($identifier, 'data', array($tag));
     $this->assertSame(\Redis::REDIS_SET, $this->redis->type('tagIdents:' . $tag));
 }
開發者ID:animaltool,項目名稱:webinterface,代碼行數:12,代碼來源:RedisBackendTest.php

示例3: testType

 public function testType()
 {
     // 0 => none, (key didn't exist)
     // 1=> string,
     // 2 => set,
     // 3 => list
     // string
     $this->redis->set('key', 'val');
     $this->assertEquals(Redis::REDIS_STRING, $this->redis->type('key'));
     // list
     $this->redis->lPush('keyList', "val0");
     $this->redis->lPush('keyList', "val1");
     $this->assertEquals(Redis::REDIS_LIST, $this->redis->type('keyList'));
     // set
     $this->redis->delete('keySet');
     $this->redis->sAdd('keySet', "val0");
     $this->redis->sAdd('keySet', "val1");
     $this->assertEquals(Redis::REDIS_SET, $this->redis->type('keySet'));
     //None
     $this->assertEquals(Redis::REDIS_NOT_FOUND, $this->redis->type('keyNotExists'));
 }
開發者ID:virtulis,項目名稱:phpredis,代碼行數:21,代碼來源:TestRedis.php

示例4: testType

 public function testType()
 {
     // 0 => none, (key didn't exist)
     // 1=> string,
     // 2 => set,
     // 3 => list,
     // 4 => zset,
     // 5 => hash
     // string
     $this->redis->set('key', 'val');
     $this->assertEquals(Redis::REDIS_STRING, $this->redis->type('key'));
     // list
     $this->redis->lPush('keyList', 'val0');
     $this->redis->lPush('keyList', 'val1');
     $this->assertEquals(Redis::REDIS_LIST, $this->redis->type('keyList'));
     // set
     $this->redis->delete('keySet');
     $this->redis->sAdd('keySet', 'val0');
     $this->redis->sAdd('keySet', 'val1');
     $this->assertEquals(Redis::REDIS_SET, $this->redis->type('keySet'));
     // sadd with numeric key
     $this->redis->delete(123);
     $this->assertTrue(1 === $this->redis->sAdd(123, 'val0'));
     $this->assertTrue(array('val0') === $this->redis->sMembers(123));
     // zset
     $this->redis->delete('keyZSet');
     $this->redis->zAdd('keyZSet', 0, 'val0');
     $this->redis->zAdd('keyZSet', 1, 'val1');
     $this->assertEquals(Redis::REDIS_ZSET, $this->redis->type('keyZSet'));
     // hash
     $this->redis->delete('keyHash');
     $this->redis->hSet('keyHash', 'key0', 'val0');
     $this->redis->hSet('keyHash', 'key1', 'val1');
     $this->assertEquals(Redis::REDIS_HASH, $this->redis->type('keyHash'));
     //None
     $this->assertEquals(Redis::REDIS_NOT_FOUND, $this->redis->type('keyNotExists'));
 }
開發者ID:stonegithubs,項目名稱:phpredis,代碼行數:37,代碼來源:TestRedis.php

示例5: testType

 public function testType()
 {
     $this->redis->set('key', 'val');
     $this->assertEquals(1, $this->redis->type('key'));
 }
開發者ID:hieutrieu,項目名稱:phpredis,代碼行數:5,代碼來源:TestRedis.php

示例6: Redis

<?php

$redis = new Redis();
#實例化redis類
$redis->connect('127.0.0.1');
#連接服務器
$redis->set('key', 'hello ');
#調用方法,設置string類型值
$redis->append('key', 'world');
#修改string類型值
echo $redis->get('key');
#獲取redis key的值,並輸出顯示
echo $redis->type('key');
#獲取key 的數據類型
echo $redis->echo('will close...');
# 輸出字符串
$redis->close();
#關閉連接
//腳本結束的時候,資源都被釋放了,一般都不寫close。
開發者ID:vipmorgana,項目名稱:PHP,代碼行數:19,代碼來源:get.php

示例7: Redis

<?php

$redis = new Redis();
$redis->connect('127.0.0.1');
$redis->set('hello', 'hehanlin');
echo $redis->get('hello');
echo $redis->type('hello');
$redis->close();
開發者ID:hehanlin,項目名稱:message,代碼行數:8,代碼來源:testredis.php

示例8: rand

$redis->zrem("zset", 456);
echo $redis->zcount("zset", 10, 50);
$redis->zRemRangeByScore("key", star, end);
echo $redis->zScore("zset", 503);
echo $redis->zrank("zset", 723);
for ($i = 0; $i < 10; $i++) {
    $redis->hset("myhash", $i, rand(10, 99) + $i);
}
echo $redis->hget("myhash", "0");
echo $redis->hlen("myhash");
echo $redis->hdel("myhash", "0");
$data = $redis->hkeys("myhash");
$data = $redis->hvals("myhash");
$data = $redis->hgetall("myhash");
echo "<pre>";
print_r($data);
echo $redis->hexists("myhash", "0");
$redis->hmset("user:1", array("name1" => "name1", "name2" => "Joe2"));
$data = $redis->hmget("user:1", array('name', 'salary'));
print_r($data);
// redis
$redis->move("key1", 2);
$redis->settimeout("user:1", 10);
$redis->expireat("myhash", time() + 23);
$count = $redis->dbSize();
$redis->auth("foobared");
$redis->bgrewriteaof();
$redis->slaveof("10.0.1.7", 6379);
print_r($redis->info());
echo $redis->type("myset");
開發者ID:isS,項目名稱:NoSQL,代碼行數:30,代碼來源:redisWithPHP.php


注:本文中的Redis::type方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。