Redis and "invalid expire time in setex"

5,065

Django has very good primitives for handling this situation. Just set up redis as one of your CACHES and use the cachr.set method to set an expiration n seconds from time of storage.

Share:
5,065

Related videos on Youtube

adamo
Author by

adamo

I am a DevOps guy living in Greece. Once upon a time I used to run sendmail a lot. http://gr.linkedin.com/in/yiorgos

Updated on September 18, 2022

Comments

  • adamo
    adamo over 1 year

    We run a Python (Django) application that temporarily stores data in Redis. Sometimes though it happens that data by the time it gets to get stored in Redis is already expired and therefore setex is called with an expiration time of <= 0.

    Is there a way to make Redis silently discard such a setex command without openly complaining with:

     ResponseError: invalid expire time in setex
    

    Right now I cannot do that from the application.