[Twisted-Python] In memory cache in twisted
Waqar Khan
wk80333 at gmail.com
Thu Sep 26 20:38:46 MDT 2019
Hi,
What's a good way to use a simple dictionary as a cache in twisted
framework?
Basically, I have this callback chain where I ultimately make a rest call
(in non-blocking way using treq) to fetch some data. But before I make the
call, I am using a dictionary to see if the value is available or not.
But, I have noticed that the event loop gets pretty busy(sometimes, things
get stuck and twisted server stops) as soon as I add this logic.. Which is
pretty much
@defer.inlinecallbacks
def fetch(key):
if key in cache:
return cache[key]
# else call back to treq to fetch value
cache[key] = value
return value
This dict can grow to around 50k.. What's a good way to solve this issue?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20190926/7b046269/attachment.html>
More information about the Twisted-Python
mailing list