本文整理汇总了Python中redis.StrictRedis.execute_command方法的典型用法代码示例。如果您正苦于以下问题:Python StrictRedis.execute_command方法的具体用法?Python StrictRedis.execute_command怎么用?Python StrictRedis.execute_command使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类redis.StrictRedis
的用法示例。
在下文中一共展示了StrictRedis.execute_command方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_rc
# 需要导入模块: from redis import StrictRedis [as 别名]
# 或者: from redis.StrictRedis import execute_command [as 别名]
def get_rc():
redis_conn = StrictRedis(
host = server_config.REDIS_HOST,
port = server_config.REDIS_PORT,
password = server_config.REDIS_PW
)
if server_config.REDIS_PW != '':
redis_conn.execute_command('AUTH %s' % server_config.REDIS_PW)
return redis_conn
示例2: test_redis_subscribed_channels_leak
# 需要导入模块: from redis import StrictRedis [as 别名]
# 或者: from redis.StrictRedis import execute_command [as 别名]
def test_redis_subscribed_channels_leak(self, manager):
if not manager.app.conf.result_backend.startswith('redis'):
raise pytest.skip('Requires redis result backend.')
redis_client = StrictRedis()
async_result = chord([add.s(5, 6), add.s(6, 7)])(delayed_sum.s())
for _ in range(TIMEOUT):
if async_result.state == 'STARTED':
break
sleep(0.2)
channels_before = \
len(redis_client.execute_command('PUBSUB CHANNELS'))
assert async_result.get(timeout=TIMEOUT) == 24
channels_after = \
len(redis_client.execute_command('PUBSUB CHANNELS'))
assert channels_after < channels_before
示例3: prep_redis
# 需要导入模块: from redis import StrictRedis [as 别名]
# 或者: from redis.StrictRedis import execute_command [as 别名]
def prep_redis(file_):
try:
LOGGER.info('Processing %s', file_)
parts = urlsplit(os.environ.get('REDIS_URI', 'redis://localhost'))
redis = StrictRedis(host=parts.hostname,
port=parts.port or 6379,
db=parts.path[1:] or 0)
with open(file_) as fh:
config = json.load(fh)
for command, entries in config.items():
for name, values in entries.items():
redis.execute_command(command, name, *values)
except Exception:
LOGGER.exception('Failed to execute redis commands.')
sys.exit(-1)
示例4: get_redis_link_wrapper
# 需要导入模块: from redis import StrictRedis [as 别名]
# 或者: from redis.StrictRedis import execute_command [as 别名]
def get_redis_link_wrapper(host, port, decode_responses=False):
link = StrictRedis(host="127.0.0.1", port=7000, decode_responses=True)
# Missing slot 5460
bad_slots_resp = [
[0, 5459, [b'127.0.0.1', 7000], [b'127.0.0.1', 7003]],
[5461, 10922, [b'127.0.0.1', 7001], [b'127.0.0.1', 7004]],
[10923, 16383, [b'127.0.0.1', 7002], [b'127.0.0.1', 7005]],
]
# Missing slot 5460
link.execute_command = lambda *args: bad_slots_resp
return link
示例5: get_redis_link_wrapper
# 需要导入模块: from redis import StrictRedis [as 别名]
# 或者: from redis.StrictRedis import execute_command [as 别名]
def get_redis_link_wrapper(*args, **kwargs):
link = StrictRedis(host="127.0.0.1", port=7000, decode_responses=True)
orig_exec_method = link.execute_command
def patch_execute_command(*args, **kwargs):
if args == ('cluster', 'slots'):
# Missing slot 5460
return [
[0, 5459, [b'127.0.0.1', 7000], [b'127.0.0.1', 7003]],
[5461, 10922, [b'127.0.0.1', 7001], [b'127.0.0.1', 7004]],
[10923, 16383, [b'127.0.0.1', 7002], [b'127.0.0.1', 7005]],
]
return orig_exec_method(*args, **kwargs)
# Missing slot 5460
link.execute_command = patch_execute_command
return link
示例6: create_event
# 需要导入模块: from redis import StrictRedis [as 别名]
# 或者: from redis.StrictRedis import execute_command [as 别名]
'buys': [ { 'who': "Jim", 'required': 20 }, { 'who': "Amy", 'required': 17 } ] }
]
for next_event in events:
create_event(next_event['event'], next_event['qty'], next_event['price'])
for buy in next_event['buys']:
reserve_with_pending(buy['who'], next_event['event'], buy['required'])
post_purchases(next_event['event'])
for next_event in events:
print "=== Event: {}".format(next_event['event'])
print "Details: {}".format(redis.hgetall("events:" + next_event['event']))
print "Sales: {}".format(redis.smembers("sales:" + next_event['event']))
for buy in next_event['buys']:
print "Invoices for {}: {}".format(buy['who'], redis.smembers("invoices:" + buy['who']))
print "=== Orders"
for i in redis.scan_iter(match="purchase_orders:*"):
print redis.get(i)
print "=== Sales Summary \n{}".format(redis.hgetall("sales_summary"))
print "=== Sales Summary - hour of sale histogram"
hist = redis.get("sales_histogram:time_of_day")
for i in range(0, 24):
vals = ["GET", "u8", (i+1) * 8]
total_sales = int(redis.execute_command("BITFIELD", "sales_histogram:time_of_day", *vals)[0])
print " {} = {}".format(i, total_sales)
示例7: execute_command
# 需要导入模块: from redis import StrictRedis [as 别名]
# 或者: from redis.StrictRedis import execute_command [as 别名]
def execute_command(self, *args, **options):
packed_args = self.pack_args(*args)
return StrictRedis.execute_command(self, *packed_args, **options)
示例8: StrictRedis
# 需要导入模块: from redis import StrictRedis [as 别名]
# 或者: from redis.StrictRedis import execute_command [as 别名]
MODULE DOCSTRING
'''
# imports std lib
# imports 3rd party libs
# imports sprayer
from itertools import izip
from redis import StrictRedis
s = StrictRedis(port=55511)
#s = StrictRedis(port=33322)
print s.ping()
print 'segundo:', s.execute_command('PING')
def get_masters():
masters_as_list = s.execute_command('SENTINEL', 'MASTERS')
masters = {}
for master_l in masters_as_list:
#convert list representing a master to a dictionary
i = iter(master_l)
master_d = dict(izip(i, i))
masters[master_d['name']] = master_d
return masters
print get_masters()
def promote_original_master(name):