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)
119
119
# We can save the model to Redis by calling `save()`:
120
120
andrew.save()
121
121
122
+ # Expire the model after 2 mins (120 seconds)
123
+ andrew.expire(120 )
124
+
122
125
# To retrieve this customer with its primary key, we use `Customer.get()`:
123
126
assert Customer.get(andrew.pk) == andrew
124
127
```
Original file line number Diff line number Diff line change @@ -553,6 +553,15 @@ andrew = Customer(
553
553
andrew.save()
554
554
```
555
555
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
+
556
565
## Examining Your Data In Redis
557
566
558
567
You can view the data stored in Redis for any Redis OM model.
You can’t perform that action at this time.
0 commit comments