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?
_______________________________________________
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
https://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Reply via email to