示例#1
0
def get_or_create_cache_token(token, user_dict):
    user_cache = LMBCache()
    if user_cache.is_exists(token):
        cached_data = user_cache.get(token)
        if cached_data['user_id'] == user_dict['user_id'] and cached_data[
                'role'] == user_dict['role']:
            user_cache.delete(token)
    token = UserAuthentication.generate_key()
    while user_cache.is_exists(token):
        token = UserAuthentication.generate_key()
    user_dict['last_modified'] = user_cache.make_datetime_version()
    user_cache.set_token(token, user_dict)
    return token
示例#2
0
def get_or_create_cache_token(token, user_dict):
    user_cache = LMBCache()
    if user_cache.is_exists(token):
        cached_data = user_cache.get(token)
        if cached_data['user_id'] == user_dict['user_id'] and cached_data['role'] == user_dict['role']:
            user_cache.delete(token)
    token = UserAuthentication.generate_key()
    while user_cache.is_exists(token):
        token = UserAuthentication.generate_key()
    user_dict['last_modified'] = user_cache.make_datetime_version()
    user_cache.set_token(token, user_dict)
    return token
示例#3
0
def get_cache(key):
    lmb_cache = LMBCache()
    return lmb_cache.get(key)
示例#4
0
 def is_authenticate(cls, token):
     lmb_cache = LMBCache()
     if lmb_cache.is_exists(token):
         return True
     return False
示例#5
0
def get_cache(key):
    lmb_cache = LMBCache()
    return lmb_cache.get(key)
示例#6
0
 def is_authenticate(cls, token):
     lmb_cache = LMBCache()
     if lmb_cache.is_exists(token):
         return True
     return False