You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
include likes and comments in the orm model and use redis to cache it .
def likes(self):
#Try to get the number of likes from Redis
likes = redis.get(f'laptime:{self.id}:likes')
if likes is None:
# If the number of likes isn't cached, query the database
likes = Like.query.filter_by(laptime_id=self.id).count()
# Cache the number of likes in Redis
redis.set(f'laptime:{self.id}:likes', likes)
return int(likes)
The text was updated successfully, but these errors were encountered:
include likes and comments in the orm model and use redis to cache it .
The text was updated successfully, but these errors were encountered: