From 747f472e7a50274f45e414c9ee4f8fe70f6f1131 Mon Sep 17 00:00:00 2001 From: Jordan Cook Date: Thu, 29 Sep 2022 15:28:04 -0500 Subject: Add ttl_offset argument for Redis backend --- docs/user_guide/backends/redis.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'docs') diff --git a/docs/user_guide/backends/redis.md b/docs/user_guide/backends/redis.md index 141834c..56df69a 100644 --- a/docs/user_guide/backends/redis.md +++ b/docs/user_guide/backends/redis.md @@ -46,12 +46,16 @@ or disabled entirely. See [Redis Persistence](https://redis.io/topics/persistenc ## Expiration Redis natively supports TTL on a per-key basis, and can automatically remove expired responses from the cache. This will be set by by default, according to normal {ref}`expiration settings `. - -Expired items are not removed immediately, but will never be returned from the cache. See -[Redis: EXPIRE](https://redis.io/commands/expire/) docs for more details. +See [Redis: EXPIRE](https://redis.io/commands/expire/) docs for more details on internal TTL behavior. If you intend to reuse expired responses, e.g. with {ref}`conditional-requests` or `stale_if_error`, -you can disable this behavior with the `ttl` argument: +you can use the `ttl_offset` argument to add additional time before deletion (default: 1 hour). +In other words, this makes backend expiration longer than cache expiration: +```python +>>> backend = RedisCache(ttl_offset=3600) +``` + +Alternatively, you can disable TTL completely with the `ttl` argument: ```python >>> backend = RedisCache(ttl=False) ``` -- cgit v1.2.1