[Twisted-Python] Caching mechanism

Marco Giusti marco.giusti at gmail.com
Mon Nov 16 06:18:40 EST 2009


On Mon, Nov 09, 2009 at 06:24:20PM -0500, vitaly at synapticvision.com wrote:
> 
> Such global variable(lets say dictionary) will have any size limit?

i don't know what kind of method calls do you need to cache, but what
about of memcached? twisted got a really handy client api for memcached
and, you should look deeper than i did, with a bit of work you can
refactor them as a decorator. memcached server also has got his policies
for size limits.

the drawback, but "bad luck often brings good luck", of this approach is
that your code must be "deferred aware".

m.

> Quoting "Andy Fundinger" <Andy at NewWorldElectric.com>:
> 
> > Part of the beauty of twisted is that you don't actually need to do anything
> > special to achieve that, just create a global dict or other object of your
> > choice and access it as needed.  More likely what you need to look for is a
> > cache expiration mechanism, I've linked in lrucache (
> > http://pypi.python.org/pypi/lrucache/0.2) in one case, but usually I just
> > write my own constraints as appropriate.
> >
> > It's often misunderstood, but in twisted you are writing an actual server
> > rather than just some methods for servicing requests.  The server will run
> > until stopped and all global or even local variables will remain in memory
> > unless deleted or dereferenced and garbage collected.  Rather than doing
> > something special to get a persistent variable you need to do something
> > special when you want a non-persistent one.
> >
> > -Andy
> >
> > On Mon, Nov 9, 2009 at 2:28 PM, <vitaly at synapticvision.com> wrote:
> >
> >>
> >>
> >> Caching the results of some particular method calls, so other server
> >> side methods can access those results (I'm thinking about example of
> >> global variable per entire server, so once imported, such variable
> >> content could be access).
> >>
> >>
> >>
> >> Quoting exarkun at twistedmatrix.com:
> >>
> >> > On 05:41 pm, vitaly at synapticvision.com wrote:
> >> >> hi,
> >> >> is there any cache mechanism for twisted? Could one point me please to
> >> >> that docs?
> >> >
> >> > What sort of caching are you interested in?  Caching the results of
> >> > method calls?  A caching HTTP proxy?  Caching in the DNS client?  The
> >> > total list of possibilities could run to many pages. :)
> >> >
> >> > Jean-Paul
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20091116/5bc2acff/attachment.pgp 


More information about the Twisted-Python mailing list