Пример #1
0
def _test_thinhash(conn):
    conn.delete('test')
    h = ThinHash('test', 10000, connection=conn)
    l = range(10)
    l.extend(range(10))
    h.hmset(*l)
    assert list(h.hmget(*range(10))) == ['1', None, '3', None, '5', None, '7', None, '9', None]
Пример #2
0
def _test_thinhash(conn):
    conn.delete('test')
    h = ThinHash('test', 10000, connection=conn)
    l = range(10)
    l.extend(range(10))
    h.hmset(*l)
    assert list(h.hmget(*range(10))) == [
        '1', None, '3', None, '5', None, '7', None, '9', None
    ]
Пример #3
0
def check_thinhashsize(count=10000):
    thinhashkey = 'testthinhash'
    conn.flushall()
    h = ThinHash(thinhashkey, count, connection=conn)
    args = []
    for _ in xrange(count):
        args.append(randid())
        args.append(randts())
    h.hmset(*args)
    print('it takes {} for {} thinhashs'.format(conn.info()['used_memory_human'], h.count()))
Пример #4
0
def check_thinhashsize(count=10000):
    thinhashkey = 'testthinhash'
    conn.flushall()
    h = ThinHash(thinhashkey, count, connection=conn)
    args = []
    for _ in xrange(count):
        args.append(randid())
        args.append(randts())
    h.hmset(*args)
    print('it takes {} for {} thinhashs'.format(
        conn.info()['used_memory_human'], h.count()))
Пример #5
0
 def gethash(type):
     hashkey = LC.hashkey.format(type)
     if type == 'item':
         count = 2 * 10000 * 10000
     elif type == 'shop':
         count = 500 * 10000
     elif type == 'shopinfo':
         count = 500 * 10000
     else:
         raise ValueError('wrong LC type: {}'.format(type))
     return ThinHash(hashkey, count, connection=conn)