Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

likes and comments feature #90

Open
vantage-ola opened this issue Jul 15, 2024 · 0 comments
Open

likes and comments feature #90

vantage-ola opened this issue Jul 15, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@vantage-ola
Copy link
Owner

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)
@vantage-ola vantage-ola added the enhancement New feature or request label Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant