Example #1
0
def kv_delete(key):
    """DELETEs `key` from key-value storage
    """
    c = KVStorageCache(prekey=key)
    c.invalidate_cache()
    kv_obj = _get_kv_obj(key)
    if kv_obj:
        kv_obj.delete()
Example #2
0
def kv_get(key, cache_only=False, force_refetch=False):
    """GETs the value of `key` from key-value storage

    `cache_only` == True : skips lookup in db, returns the cached value or None
    """
    c = KVStorageCache(prekey=key)
    if force_refetch:
        c.invalidate_cache()
    value = c.get()
    if value is None and not cache_only:
        kv_obj = _get_kv_obj(key)
        if kv_obj:
            value = kv_obj.value
            c.cache_store(value)
    return value