stasdavydov
stasdavydov

Reputation: 383

Django Channels message life time

I have some (possibly huge) amount of JSON data I need to push into Django Channel. The data has very small required lifetime (2-3 seconds is enough). I use Redis as backend.

What is default message lifetime? Is it possible to specify life time of the message?

Upvotes: 1

Views: 939

Answers (2)

stasdavydov
stasdavydov

Reputation: 383

I found an easy way to resolve my issue without patching asgi_redis code for customer expiry of message.

I created two channel layers in my configuration. Then I set desired short expiry to the second channel layer. All short live time messages now passed and handled by this channel layer consumer.

Upvotes: 0

Chris Tanner
Chris Tanner

Reputation: 1650

By default there's no limit to the lifetime, but you can set one by using SETEX instead of SET:

SETEX mykey 10 "Hello"

or by using SET with the EX flag:

SET mykey "Hello" EX 10

Upvotes: 1

Related Questions