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

[Feature Request] Allow default expiry time for a model #529

Open
XChikuX opened this issue Jun 20, 2023 · 1 comment
Open

[Feature Request] Allow default expiry time for a model #529

XChikuX opened this issue Jun 20, 2023 · 1 comment

Comments

@XChikuX
Copy link

XChikuX commented Jun 20, 2023

Currently we are able to set an expiry after saving the model.

class Like(HashModel):
    user_id: str
    liked_user_id: str

    @root_validator()
    def assign_pk(cls, values):
        values["pk"] = f"{values['user_id']}:{values['liked_user_id']}"
        return values

    class Meta:
        database = redis_conn

like1 = Like(user_id="1", liked_user_id="2")
like1.expire(120)

I'd like all my 'Like' instances to have a default expiry time, instead of defining it each time and updating redis in the background.

@javitab
Copy link

javitab commented Oct 31, 2023

I would also like to see this as a feature under the Meta class, but I think you could honestly do this just as easily by overriding the built-in save method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants