Caching vs memoization

64 views
Skip to first unread message

Sean Walberg

unread,
Aug 28, 2013, 2:06:49 AM8/28/13
to typh...@googlegroups.com
I've got an app where a few different classes enqueue requests into Hydra and then the queue is run. Many of these requests could be the same (same url, same options hash) so that in the end I might have 8 requests going to the same server but it's really 2 unique requests requested by 4 different classes. I've verified that Hydra::Request#eql? is true for the similar ones and that memoization is turned on.

What I've noticed is that with a high concurrency, all the requests hit the remote server (e.g. 8). If I turn concurrency down to 1 (like in the docs for memoization) then I only see the unique requests (e.g. 2) at the remote server.

Is this the intended behaviour of memoization? Should I be using caching instead? 

Thanks,

Sean

Hans Hasselberg

unread,
Aug 29, 2013, 7:25:18 AM8/29/13
to typh...@googlegroups.com
Hey Sean,

that is intentionally. The problem is that all the requests are started at the same time. The memoization checks when the request is started if a similar request was already done. But that hasn't happened yet with default concurrency.
I just realized that the memoization could be smarter and see that similiar requests are started and only do one of them and set the response to all of them. But right now thats not the case.


--
You received this message because you are subscribed to the Google Groups "Typhoeus" group.
To unsubscribe from this group and stop receiving emails from it, send an email to typhoeus+u...@googlegroups.com.
To post to this group, send email to typh...@googlegroups.com.
Visit this group at http://groups.google.com/group/typhoeus.
For more options, visit https://groups.google.com/groups/opt_out.

Sean Walberg

unread,
Aug 30, 2013, 6:00:59 PM8/30/13
to typh...@googlegroups.com
Thanks for the clarification.

Does caching have the same behaviour? I was playing around with a cache object and it didn't solve my problem.

Thanks,

Sean
Reply all
Reply to author
Forward
0 new messages