Exemple #1
0
def _test_thinset(conn):
    conn = Redis(db=1)
    conn.delete('test')
    s = ThinSet('test', 10000, connection=conn)
    l = range(10) 
    s.add(*l)
    assert s.contains(*range(0, 20, 2)) == [True, True, True, True, True, False, False, False, False, False]
Exemple #2
0
def check_thinsetsize(count=10000):
    thinsetkey = 'testthinset'
    conn.flushall()
    s = ThinSet(thinsetkey, count, connection=conn)
    s.add(*[randid() for _ in xrange(0, count)])
    print('it takes {} for {} thinsets'.format(
        conn.info()['used_memory_human'], s.count()))
Exemple #3
0
def _test_thinset(conn):
    conn = Redis(db=1)
    conn.delete('test')
    s = ThinSet('test', 10000, connection=conn)
    l = range(10)
    s.add(*l)
    assert s.contains(*range(0, 20, 2)) == [
        True, True, True, True, True, False, False, False, False, False
    ]
Exemple #4
0
def check_thinsetsize(count=10000):
    thinsetkey = 'testthinset'
    conn.flushall()
    s = ThinSet(thinsetkey, count, connection=conn)
    s.add(*[randid() for _ in xrange(0, count)])
    print('it takes {} for {} thinsets'.format(conn.info()['used_memory_human'], s.count()))
Exemple #5
0
 def __init__(self, date):
     self.date = date
     self.conn = getconn(date)
     self.pipeline = None
     self.allshopids = ThinSet(self.shopids.format(self.date), 5000000,
                               self.conn)
Exemple #6
0
 def getset(setkey):
     cache = ItemCT.cache
     if setkey not in cache:
         cache[setkey] = ThinSet(setkey, 20 * 10000, connection=conn)
     return cache[setkey]
Exemple #7
0
import traceback

from thinredis import ThinSet, ThinHash
from shardredis import ShardRedis
from settings import CACHE_URIS
import debouncing

conns = []
for uri in CACHE_URIS:
    host, port, db = re.compile('redis://(.*):(\d+)/(\d+)').search(
        uri).groups()
    conn = redis.Redis(host=host, port=int(port), db=int(db))
    conns.append(conn)
conn = ShardRedis(conns=conns)

WC = ThinSet('ataobao-wrongcategory-items', 3000 * 10000, connection=conn)

from settings import RECORD_URI

host, port, db = re.compile('redis://(.*):(\d+)/(\d+)').search(
    RECORD_URI).groups()
conn_record = redis.Redis(host=host, port=int(port), db=int(db))


class LC(object):
    """ Item LastCheck Management 

    This is a huge hash table maps:
        
        - field -> item id/ shop id
        - value -> last time checked