Пример #1
0
 def __init__(self, addr="127.0.0.1", port=9999, timeout=None):
     self.port = port
     self.redis = credis.Connection(host=addr,
                                    port=port,
                                    socket_timeout=timeout)
     self.connect()
     self.fallbackredis = None
Пример #2
0
def test():
    conn = credis.Connection(decode_responses=True)
    conn.execute('del', 'btc_usdt')
    assert conn.execute('agg.new', 'btc_usdt', 'time', 'price', 'amount',
                        'value') == 'OK'
    assert conn.execute('agg.view', 'btc_usdt', 'kline_1m', 'interval', 60,
                        'first', 'price', 'max', 'price', 'min', 'price',
                        'last', 'price', 'sum', 'amount', 'sum',
                        'value') == 'OK'
    assert conn.execute('agg.insert', 'btc_usdt', '1564390729000-0', 1001.11,
                        1.0, 1001.11 * 1.0) == '1564390729000-0'
    with pytest.raises(credis.base.RedisReplyError):
        conn.execute('agg.insert', 'btc_usdt', '1564390729000-0', 1005.11, 1.0,
                     1005.11 * 1.0)
    conn.execute('agg.insert', 'btc_usdt', '1564390729000-1', 1005.11, 1.0,
                 1005.11 * 1.0) == '1564390729000-1'
    assert conn.execute('agg.insert', 'btc_usdt', '1564390731000-0', 999.11,
                        1.0, 999.11 * 1.0) == '1564390731000-0'
    assert conn.execute('agg.insert', 'btc_usdt', '1564390732000-0', 1003.11,
                        1.0, 1003.11 * 1.0) == '1564390732000-0'
    name, values, time = conn.execute('agg.current', 'btc_usdt')
    assert name == 'kline_1m'
    assert tuple(values) == ('1001.11', '1005.11', '999.11000000000001',
                             '1003.11', '4', '4008.4400000000001')
    assert time == '1564390680'
Пример #3
0
def worker():
    root = options['--path']
    for host, port in JOBS:
        try:
            conn = credis.Connection(host=host, port=port)
            global recentInputEventHandled
            lastInputEventHandled = int(
                conn.execute('get', 'app::lastInputEventHandled'))
            if lastInputEventHandled - recentInputEventHandled > 100000:
                recentInputEventHandled = lastInputEventHandled
                print 'found recent input event handled', recentInputEventHandled
                os.link(
                    os.path.join(root, 'dump.rdb'),
                    os.path.join(root,
                                 'dump.rdb.%s' % recentInputEventHandled))
        except:
            traceback.print_exc()
Пример #4
0
def test(redis_port):
    conn = credis.Connection(port=redis_port, decode_responses=True)
    conn.execute("del", "btc_usdt")
    assert (conn.execute("agg.new", "btc_usdt", "time", "price", "amount",
                         "value") == "OK")
    assert (conn.execute(
        "agg.view",
        "btc_usdt",
        "kline_1m",
        "interval",
        60,
        "first",
        "price",
        "max",
        "price",
        "min",
        "price",
        "last",
        "price",
        "sum",
        "amount",
        "sum",
        "value",
    ) == "OK")
    assert (conn.execute("agg.insert", "btc_usdt", "1564390729000-0", 1001.11,
                         1.0, 1001.11 * 1.0) == "1564390729000-0")
    with pytest.raises(credis.base.RedisReplyError):
        conn.execute("agg.insert", "btc_usdt", "1564390729000-0", 1005.11, 1.0,
                     1005.11 * 1.0)
    conn.execute("agg.insert", "btc_usdt", "1564390729000-1", 1005.11, 1.0,
                 1005.11 * 1.0) == "1564390729000-1"
    assert (conn.execute("agg.insert", "btc_usdt", "1564390731000-0", 999.11,
                         1.0, 999.11 * 1.0) == "1564390731000-0")
    assert (conn.execute("agg.insert", "btc_usdt", "1564390732000-0", 1003.11,
                         1.0, 1003.11 * 1.0) == "1564390732000-0")
    name, values, time = conn.execute("agg.current", "btc_usdt")
    assert name == "kline_1m"
    assert tuple(values) == (
        "1001.11",
        "1005.11",
        "999.11000000000001",
        "1003.11",
        "4",
        "4008.4400000000001",
    )
    assert time == "1564390680"
def main():
    root = options['--path']
    host = options['--host']
    port = int(options['--port'])

    print 'process redis path %s, %s:%s' % (root, host, port)

    # make hard link
    last_timestamp = find_last_timestamp(os.path.join(root, 'appendonly.aof'))

    print 'found last timestamp', last_timestamp, datetime.datetime.fromtimestamp(
        last_timestamp)
    os.link(os.path.join(root, 'appendonly.aof'),
            os.path.join(root, 'appendonly.aof.%s' % last_timestamp))

    # do bgrewriteaof
    print 'do bgrewriteaof', host, port
    credis.Connection(host=host, port=port).execute('bgrewriteaof')
Пример #6
0
import cpipelib
import credis
import time
import redis
from time import time
import pandas as pd

retry_attempts = 1
pipe_sizes = [100, 500, 1000, 5000, 10000, 50000, 100000]
hashmap_sizes = [1000, 5000, 10000, 25000, 50000, 75000, 100000]

HOST = '127.0.0.1'
PORT = 6379

# Credis connection
r = credis.Connection()

# Golang extension connection
cpipe.Connect(HOST, PORT)

# Golang extension connection with golang lib
cpipelib.Connect(HOST, PORT)

# Redispy connection
redispy = redis.Redis()


def timeit(method):
    def timed(*args, **kw):
        sum_time = 0
        l = list()
Пример #7
0
 def __init__(self, addr="127.0.0.1", port=9999):
     self.redis = credis.Connection(host=addr, port=port)
     self.redis.connect()
     self.fallbackredis = j.clients.redis.getRedisClient(addr, port)
def worker():
    for host, port in JOBS:
        try:
            credis.Connection(host=host, port=port).execute('set', 'redis_timestamp_key', int(time.time()))
        except:
            traceback.print_exc()