Django

Code

Ticket #9595 (new)

Opened 2 years ago

Last modified 8 months ago

Add support for cache to not expire

Reported by: keseldude Assigned to: nobody
Milestone: Component: Cache system
Version: 1.0 Keywords: cache timeout
Cc: mkdzmail@gmail.com, justinlilly@gmail.com, jbalogh Triage Stage: Design decision needed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 1

Description

I noticed that for the memcached backend, it is not possible (without modifying the backend code) to actually set the cache timeout value to 0, meaning the cache will not expire. Instead, it sets the timeout value to the 'default_timeout', which is not always preferable. This patch should fix that and make the memcached backend that much more flexible.

The path to the file is django/core/cache/backends/memcached.py.

Attachments

memcached.diff (0.7 kB) - added by keseldude on 11/13/08 21:50:40.
Patch that allows the cache timeout to actually be 0, thus allowing it to not expire.

Change History

11/13/08 21:50:40 changed by keseldude

  • attachment memcached.diff added.

Patch that allows the cache timeout to actually be 0, thus allowing it to not expire.

11/13/08 21:52:39 changed by mtredinnick

  • needs_better_patch set to 1.
  • needs_tests changed.
  • needs_docs changed.

That patch is backwards-incompatible (not necessarily in a documented way, but in practice), so can't be taken as is (if it was that easy, we would have done it ages ago). There's some argument for allowing "don't expire" in the cache backend, but it needs a different way of specifying it.

(follow-up: ↓ 4 ) 11/13/08 22:11:29 changed by keseldude

At which version [of memcached] does the patch become backwards-incompatible? It might be better to accept it if the version is really old and/or there is no reason to use the older versions.

11/13/08 22:15:19 changed by mtredinnick

It's not about memcached. It's about Django. Existing Django code that passes in 0 for the cache timeout currently behaves in a particular, well-defined way. Your patch changes that behaviour.

(in reply to: ↑ 2 ) 11/13/08 22:18:21 changed by keseldude

Ah, I see now. Thanks for the clarification :).

02/07/09 17:40:31 changed by justinlilly

  • cc changed from mkdzmail@gmail.com to mkdzmail@gmail.com, justinlilly@gmail.com.

Forgive my ignorance, but does the current system do something special with a cache timeout of 0? Or is it just "Stash this for 0 second" at which point I question why caches something for 0 seconds?

02/26/09 16:29:07 changed by jacob

  • stage changed from Unreviewed to Design decision needed.

01/22/10 20:53:39 changed by jbalogh

  • cc changed from mkdzmail@gmail.com, justinlilly@gmail.com to mkdzmail@gmail.com, justinlilly@gmail.com, jbalogh.

Add/Change #9595 (Add support for cache to not expire)




Change Properties
Action