示例#1
0
文件: utils.py 项目: piokuc/stests
def _get_all(store: typing.Callable, search_key: str) -> typing.List[typing.Any]:
    """Wraps redis.mget command.
    
    """
    CHUNK_SIZE = 5000
    _, keys = store.scan(match=search_key, count=CHUNK_SIZE)

    return [_decode_item(i) for i in store.mget(keys)] if keys else []
示例#2
0
文件: utils.py 项目: dwerner/stests
def _get_many(store: typing.Callable,
              search_key: SearchKey) -> typing.List[typing.Any]:
    """Returns collection cached under all matched keys.
    
    """
    keys = []
    chunk_size = 2000
    cursor = '0'
    while cursor != 0:
        cursor, keys_ = store.scan(cursor=cursor,
                                   match=search_key.key,
                                   count=chunk_size)
        keys += keys_

    return [_decode_item(i) for i in store.mget(keys)] if keys else []
示例#3
0
文件: utils.py 项目: dwerner/stests
def _get_counter_many(
        store: typing.Callable, search_key: SearchKey
) -> typing.Tuple[typing.List[str], typing.List[int]]:
    """Returns counts under matched keys.
    
    """
    keys = []
    chunk_size = 1000
    cursor = '0'
    while cursor != 0:
        cursor, keys_ = store.scan(cursor=cursor,
                                   match=search_key.key,
                                   count=chunk_size)
        keys += keys_

    return [i.decode('utf8') for i in keys], [int(i) for i in store.mget(keys)]