Exemple #1
0
def _set_one_singleton(store: typing.Callable,
                       item: Item) -> typing.Tuple[str, bool]:
    """Sets item under a key if not already cached.
    
    """
    key, was_cached = item.key, bool(store.setnx(item.key, item.data_as_json))
    if was_cached and item.expiration:
        store.expire(key, item.expiration)

    return key, was_cached