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


Python StrictRedisCluster.keys方法代码示例

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


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

示例1: getRedisKeyValues

# 需要导入模块: from rediscluster import StrictRedisCluster [as 别名]
# 或者: from rediscluster.StrictRedisCluster import keys [as 别名]
def getRedisKeyValues(host, port, keyFilter):

    try:
        startup_nodes = [{"host": host, "port": port}]
        rc = StrictRedisCluster(startup_nodes=startup_nodes, decode_responses=True)
        info = rc.info()
        for key in info:
            print "%s: %s" % (key, info[key])

        result = []
        # keysCount = len(rc.keys())

        count = 0
        for key in rc.keys():
            if count >= 1024:
                break
            else:
                if key.find(keyFilter) != -1:
                    count += 1
                    # 查询类型
                    # (key, value)
                    result.append([key, getValue(rc, key)])
            #        pprint.pprint("type:" + rc.type(key) + "$key:" + key + "$value:" + getValue(rc, key))
            #        print rc.get(key)
        return result
    except Exception, e:
        return [["<font color='red'>Error Info</font>", "<font color='red'>%s</font>" % (str(e) + "<br/>请检查ip和端口是否正确")]]
开发者ID:junfeng-feng,项目名称:PancloudTools,代码行数:29,代码来源:myRedisCluster.py

示例2: StrictRedisCluster

# 需要导入模块: from rediscluster import StrictRedisCluster [as 别名]
# 或者: from rediscluster.StrictRedisCluster import keys [as 别名]
#!/usr/bin/env python
# _*_coding:utf-8_*_
# Author: create by yang.hong
# Time: 2018-08-17 11:06
"""
集群模式下,匹配方式删除多个key
"""

from rediscluster import StrictRedisCluster

redis_cluster = [{'host': '172.28.246.12', 'port': '28000'},
                 {'host': '172.28.246.12', 'port': '28001'},
                 {'host': '172.28.246.12', 'port': '28002'},
                 {'host': '172.28.246.12', 'port': '28003'},
                 {'host': '172.28.246.12', 'port': '28004'},
                 {'host': '172.28.246.12', 'port': '28005'},
                 ]

r = StrictRedisCluster(startup_nodes=redis_cluster, decode_responses=True)
print r.keys(pattern="*mc_payChannel_router*")
r.delete(*r.keys(pattern="*mc_payChannel_router*"))
开发者ID:jameyang,项目名称:python,代码行数:23,代码来源:redis_del_v2.py

示例3: xrange

# 需要导入模块: from rediscluster import StrictRedisCluster [as 别名]
# 或者: from rediscluster.StrictRedisCluster import keys [as 别名]
import redis
from rediscluster import StrictRedisCluster
serverip='101.200.214.57'
serverip='192.168.1.146'

startup_nodes=[{"host": serverip,"port": i} for i in xrange(7003, 7004)]
print startup_nodes

r = StrictRedisCluster(startup_nodes=startup_nodes)

print r.keys()
#print r.hgetall("41_56a466e0ce65")

开发者ID:9wfox,项目名称:robot,代码行数:14,代码来源:test.py

示例4: len

# 需要导入模块: from rediscluster import StrictRedisCluster [as 别名]
# 或者: from rediscluster.StrictRedisCluster import keys [as 别名]
    #    for key in info:
    #      print "%s: %s" % (key, info[key])

    #    pprint.pprint(dir(rc))

    print "-------------------"

    #    pprint.pprint( rc.keys())
    # zset
    rc.zadd("zset_", 9000, "zset.cc")
    # set
    rc.sadd("set_", "set.cc")
    # hash
    rc.hset("hash", "filed", "123456789")
    # string
    rc.set("foo", "xiaorui.cc")
    # list
    rc.lpush("list", "1")
    rc.lpush("list", "2")

    keysCount = len(rc.keys())
    if keysCount < 1024:
        for key in rc.keys():
            # 查询类型
            pprint.pprint("type:" + rc.type(key) + "$key:" + key + "$value:" + getValue(rc, key))
    #        print rc.get(key)
    else:
        print "keysCount:" + str(keysCount)
    pass
开发者ID:junfeng-feng,项目名称:PancloudTools,代码行数:31,代码来源:myRedisCluster.py


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