def _get_counter_one(store: typing.Callable, item_key: ItemKey) -> int: """Returns count under exactly matched key. """ count = store.get(item_key.key) return 0 if count is None else int(count)
def _get(store: typing.Callable, key: str) -> typing.Any: """Wraps redis.get command. """ obj = store.get(key) if obj is not None: return _decode_item(obj)
def _get_one_from_many(store: typing.Callable, item_key: ItemKey) -> typing.Any: """Returns item under first matched key. """ chunk_size = 1000 cursor = '0' while cursor != 0: cursor, keys = store.scan(cursor=cursor, match=item_key.key, count=chunk_size) if keys: return _decode_item(store.get(keys[0]))
def _get_one(store: typing.Callable, item_key: ItemKey) -> typing.Any: """Returns item under exactly matched key. """ return _decode_item(store.get(item_key.key))