Re: [Twisted-Python] In memory cache in twisted

2019-09-27 Thread meejah
Waqar Khan writes: > But, is the above way of using dictionary as cache correct? Or is > there a "deffered" way of doing this? All I want is an inmemory cache > that is compatible with this async paradigm? Yes, it is fine to use a single dict as a cache. Twisted is single-threaded an so only on

Re: [Twisted-Python] In memory cache in twisted

2019-09-26 Thread Ilya Skriblovsky
Hi all, Here is async in-memory cache that I've implemented for one of my projects: https://gist.github.com/IlyaSkriblovsky/5aba53b661acd49b65efeb4ce41a8b52 It properly handles problem #2 described by Maarten. But it doesn't bother with eviction because it wasn't needed at the time of writing (be

Re: [Twisted-Python] In memory cache in twisted

2019-09-26 Thread Maarten ter Huurne
On Friday, 27 September 2019 05:48:35 CEST Waqar Khan wrote: > Hi Maarten, >I think you have hit the problem in the head. I do think this is > feasible as I have observed that as size of cache increases, things do > get better which might support your theory. > > Is there a simple example you

Re: [Twisted-Python] In memory cache in twisted

2019-09-26 Thread Waqar Khan
Hi Maarten, I think you have hit the problem in the head. I do think this is feasible as I have observed that as size of cache increases, things do get better which might support your theory. Is there a simple example you can add on "put a Deferred for the fetch operation ". I am really just ge

Re: [Twisted-Python] In memory cache in twisted

2019-09-26 Thread Maarten ter Huurne
On Friday, 27 September 2019 04:38:46 CEST Waqar Khan wrote: > 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 ma

Re: [Twisted-Python] In memory cache in twisted

2019-09-26 Thread Waqar Khan
Good point. Thanks for responding. But, is the above way of using dictionary as cache correct? Or is there a "deffered" way of doing this? All I want is an inmemory cache that is compatible with this async paradigm? On Thu, Sep 26, 2019 at 10:45 PM Gelin Yan wrote: > Hi > > I don't see any r

Re: [Twisted-Python] In memory cache in twisted

2019-09-26 Thread Gelin Yan
Hi I don't see any reason to use defer.inlineCallbacks in your snippet of codes. Regards gelin yan ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com https://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

[Twisted-Python] In memory cache in twisted

2019-09-26 Thread Waqar Khan
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