当前位置: 首页>>代码示例>>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;未经允许,请勿转载。