Updated docs with expire.

This commit is contained in:
Simon Prickett 2022-03-29 22:19:08 +01:00
parent b42e63606a
commit 93aa9f7507
2 changed files with 12 additions and 0 deletions

View file

@ -119,6 +119,9 @@ print(andrew.pk)
# We can save the model to Redis by calling `save()`: # We can save the model to Redis by calling `save()`:
andrew.save() andrew.save()
# Expire the model after 2 mins (120 seconds)
andrew.expire(120)
# To retrieve this customer with its primary key, we use `Customer.get()`: # To retrieve this customer with its primary key, we use `Customer.get()`:
assert Customer.get(andrew.pk) == andrew assert Customer.get(andrew.pk) == andrew
``` ```

View file

@ -553,6 +553,15 @@ andrew = Customer(
andrew.save() andrew.save()
``` ```
## Expiring Models
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:
```python
# Expire Andrew in 2 minutes (120 seconds)
andrew.expire(120)
```
## Examining Your Data In Redis ## Examining Your Data In Redis
You can view the data stored in Redis for any Redis OM model. You can view the data stored in Redis for any Redis OM model.