def test_transaction(self): with_transaction = hot_redis.List([1]) without_transaction = hot_redis.List(key=with_transaction.key, client=hot_redis.HotClient()) with hot_redis.transaction(): with_transaction.append(1) self.assertEqual(len(without_transaction), 1) self.assertEqual(len(without_transaction), 2)
☷ ''' import os import sys app_root = '/'.join(os.path.abspath(__file__).split('/')[:-2]) sys.path.append(app_root) import click import hot_redis import redis from cde import REDIS_CONF rdb_out = hot_redis.HotClient(**REDIS_CONF) rd = redis.StrictRedis(**REDIS_CONF) def hot_redis_test(clear=False): """ 测试 hot redis 常用功能 :return: """ # clear = True dat = { 'base': 10, 'crx': 2, 'jobbole': 1, }
def client(*args, **kwargs): return hr.HotClient(*args, **kwargs)
def __init__(self): # url = urlparse.urlparse(os.environ.get('REDISCLOUD_URL')) # self.redis = redis.Redis(host=url.hostname, port=url.port, password=url.password) self.redis = redis.Redis(host='localhost', port=6379) self.connection = hot_redis.HotClient(host='localhost', port=6379)