File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -119,6 +119,9 @@ print(andrew.pk)
119119# We can save the model to Redis by calling `save()`:
120120andrew.save()
121121
122+ # Expire the model after 2 mins (120 seconds)
123+ andrew.expire(120 )
124+
122125# To retrieve this customer with its primary key, we use `Customer.get()`:
123126assert Customer.get(andrew.pk) == andrew
124127```
Original file line number Diff line number Diff line change @@ -553,6 +553,15 @@ andrew = Customer(
553553andrew.save()
554554```
555555
556+ ## Expiring Models
557+
558+ We can expire an instance of a model using ` expire ` , and passing it the number of seconds after which we want the instance to expire in Redis:
559+
560+ ``` python
561+ # Expire Andrew in 2 minutes (120 seconds)
562+ andrew.expire(120 )
563+ ```
564+
556565## Examining Your Data In Redis
557566
558567You can view the data stored in Redis for any Redis OM model.
You can’t perform that action at this time.
0 commit comments