Re: Feature request: ttl method for cache

2014-05-09 Thread Malcolm Box
Ticket filed and pull request for fix https://code.djangoproject.com/ticket/22606 On 9 May 2014 10:38, Malcolm Box wrote: > > On Thursday, 8 May 2014 16:59:55 UTC+1, Piotr Gosławski wrote: >> >> I was fixing my little helper function to behave more like Sean's and I >> think I've found a bug in

Re: Feature request: ttl method for cache

2014-05-09 Thread Malcolm Box
On Thursday, 8 May 2014 16:59:55 UTC+1, Piotr Gosławski wrote: > > I was fixing my little helper function to behave more like Sean's and I > think I've found a bug in locmem. Could you please take a look at this: > > Either I'm missing something or has_key() is not working correctly for > keys w

Re: Feature request: ttl method for cache

2014-05-08 Thread Piotr Gosławski
I was fixing my little helper function to behave more like Sean's and I think I've found a bug in locmem. Could you please take a look at this: >>> cache >>> cache.set('a', 1) >>> cache.set('b', 2, None) >>> cache.get('a') 1 >>> cache.get('b') 2 >>> cache.has_key('a') True >>> cache.has_key('b')

Re: Feature request: ttl method for cache

2014-05-07 Thread Piotr Gosławski
It would sacrifice atomicity of incr()/decr() methods and hit their speed pretty hard. W dniu wtorek, 6 maja 2014 16:47:53 UTC+2 użytkownik adamcik napisał: > > On Tue, May 06, 2014 at 05:57:28AM -0700, Piotr Gosławski wrote: > > W dniu wtorek, 6 maja 2014 11:47:17 UTC+2 użytkownik Florian Apoll

Re: Feature request: ttl method for cache

2014-05-07 Thread Piotr Gosławski
W dniu wtorek, 6 maja 2014 16:47:53 UTC+2 użytkownik adamcik napisał: > > See > https://groups.google.com/d/msg/django-developers/ctKJzBTONu8/opbWqUIcOKgJ > for a similar case that has come up before. The tuple solution used there > could easily be adapted to store the time the key will expire,

Re: Feature request: ttl method for cache

2014-05-06 Thread Thomas K. Adamcik
On Tue, May 06, 2014 at 05:57:28AM -0700, Piotr Gosławski wrote: > W dniu wtorek, 6 maja 2014 11:47:17 UTC+2 użytkownik Florian Apolloner > napisał: > > > > [...] > > Memcached doesn't provide access to the remaining TTL, and I don't see how > > we can reasonably fake this without writing an extr

Re: Feature request: ttl method for cache

2014-05-06 Thread Michael Manfre
On Tue, May 6, 2014 at 8:57 AM, Piotr Gosławski wrote: > W dniu wtorek, 6 maja 2014 11:47:17 UTC+2 użytkownik Florian Apolloner > napisał: >> >> [...] >> >> Memcached doesn't provide access to the remaining TTL, and I don't see >> how we can reasonably fake this without writing an extra key contai

Re: Feature request: ttl method for cache

2014-05-06 Thread Piotr Gosławski
W dniu wtorek, 6 maja 2014 11:47:17 UTC+2 użytkownik Florian Apolloner napisał: > > [...] > Memcached doesn't provide access to the remaining TTL, and I don't see how > we can reasonably fake this without writing an extra key containing the > expiration date. > > Would that be unacceptable to a

Re: Feature request: ttl method for cache

2014-05-06 Thread Russell Keith-Magee
On Tue, May 6, 2014 at 5:47 PM, Florian Apolloner wrote: > Hi Russ, > > > On Tuesday, May 6, 2014 2:54:52 AM UTC+2, Russell Keith-Magee wrote: >> >> As far as the NotImplemented bit goes - I'd rather see this implemented >> for all officially supported backends, rather than only one backend. The >

Re: Feature request: ttl method for cache

2014-05-06 Thread Florian Apolloner
Hi Russ, On Tuesday, May 6, 2014 2:54:52 AM UTC+2, Russell Keith-Magee wrote: > > As far as the NotImplemented bit goes - I'd rather see this implemented > for all officially supported backends, rather than only one backend. The > only exception to this would be if there is a fundamental technic

Re: Feature request: ttl method for cache

2014-05-05 Thread Sean Bleier
Hi Piotr, For what it's worth, I have an implementation of ttl on django-redis-cache: https://github.com/sebleier/django-redis-cache/commit/626a3263c428cf59b1428f5fc2aa638efd77346a It's slightly different from your snippet in that if the key does not exist (because it is expired or didn't exist i

Re: Feature request: ttl method for cache

2014-05-05 Thread Russell Keith-Magee
On Tue, May 6, 2014 at 4:16 AM, Piotr Gosławski wrote: > Hi! > > Since the contribution workflow is a bit confusing to me, I'll just leave > it here. > I think django's cache needs ttl (time to live) method that would return > time left until specified key expires. I, for instance, needed one when

Feature request: ttl method for cache

2014-05-05 Thread Piotr Gosławski
Hi! Since the contribution workflow is a bit confusing to me, I'll just leave it here. I think django's cache needs ttl (time to live) method that would return time left until specified key expires. I, for instance, needed one when writing a rate limiter. Without it I would have to store twice a