2 years ago

#153054

test-img

fahime

RedisCache' object has no attribute 'ttl'

hello friends in new project i use Django4 and i set the "django.core.cache.backends.redis.RedisCache" for the cache but i have the error it say "AttributeError: 'RedisCache' object has no attribute 'ttl'" .it refer to the line of my code that i add it below :

from django.core.cache import cache

def validate_token(token, check_time=True):
 if cache.ttl(token) == 0:
     return False
 try:
     data = claim_token(token)
 except Exception:
    return False
 if "type" not in data.keys():
    return False

can anyone tell me how i can resolve it ? (i know ttl mean time to live)

python

django

redis-cache

django-redis

django-4.0

0 Answers

Your Answer

Accepted video resources