cache-like structure

maxime maximesteisel at gmail.com
Thu Aug 7 13:18:32 EDT 2008


On Aug 7, 7:00 pm, maxime <maximestei... at gmail.com> wrote:
> konstantin wrote:
> > Hi,
> Hi
> >...
> > - are there better ways to do this (or any ready recipes)
>
> Did you consider using the shed module (not threaded)?
>
> Cheers,
>
> Maxime

If you need threading, what i would do is implementing a _remove
method like:
def _remove(self, rec): #try not to use __form, almost always an error
    self.records.remove(rec)

the Timer would become
Timer(ttl, self._remove, [(t, item)]) # t is the time that you got
before

And if you change the deque for a Queue.Queue, you don't even need a
Lock...

Cheers,

Maxime



More information about the Python-list mailing list