Exemplo n.º 1
0
def save_token_in_cache(key, value, **kwargs):
    ''' save user token in cache '''
    cache_obj = CacheHandler(CACHE)
    cache_obj.set_object(key, value, **kwargs)
    ''' set expiration time for token '''
    if isinstance(value, dict):
        if value.has_key("expire_at"):
            if hasattr(cache_obj.get_cache_object(), "expire"):
                _expire_at = value.get("expire_at")
                cache_obj.expire(ttl=_expire_at)
Exemplo n.º 2
0
def delete_from_cache(key, **kwargs):
    cache_obj = CacheHandler(CACHE)
    key_exists = cache_obj.exists(str(key))
    if key_exists:
        cache_obj.delete(str(key))