From 93aa9f75076e029273e2b3624f2c5eea5a171215 Mon Sep 17 00:00:00 2001 From: Simon Prickett Date: Tue, 29 Mar 2022 22:19:08 +0100 Subject: [PATCH] Updated docs with expire. --- README.md | 3 +++ docs/getting_started.md | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/README.md b/README.md index 9e7607a..32ca32c 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,9 @@ print(andrew.pk) # We can save the model to Redis by calling `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()`: assert Customer.get(andrew.pk) == andrew ``` diff --git a/docs/getting_started.md b/docs/getting_started.md index f80d8dd..5f43086 100644 --- a/docs/getting_started.md +++ b/docs/getting_started.md @@ -553,6 +553,15 @@ andrew = Customer( 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 You can view the data stored in Redis for any Redis OM model.