Hi Oleg, I took a quick look, and see where you are going with this. My only suggestion here is that I'm not sure that an HttpCache and a ResourceFactory should both be constructors to the CachingHttpClient; this feels to me like the CachingHttpClient is getting a little too deep into the details of how the cache is going about managing its storage, which ought not to be the concern of the CachingHttpClient.
I think this can be addressed pretty simply, though, by altering the HttpCache interface appropriately, and pushing the details of Resources and ResourceFactories down into the classes that implement HttpCache. (So, for example, the constructor for the BasicHttpCache might instantiate a HeapResourceFactory itself, and the ManagedHttpCache could take a constructor where you can pass in a ResourceFactory). This simplifies the code in CachingHttpClient (probably just by moving it elsewhere). I suspect this means that the BasicHttpCache can go back to not being concerned with Resources or ResourceFactories at all (which I would suggest is simpler and clearer). This then gives you flexibility to add cache implementations along several ways: 1. implement HttpCache outright (e.g. the memcached and ehcache packages we're working on contributing) 2. subclass or write analogues to the ManagedHttpCache and inject existing ResourceFactories 3. re-use the ManagedHttpCache and write a new ResourceFactory I think this maximizes flexibility while not adding complexity where it isn't needed. I can take a stab at the rewrite I'm suggesting here if you don't have time, although probably not until next week. Jon -----Original Message----- From: Oleg Kalnichevski [mailto:[email protected]] Sent: Thursday, August 12, 2010 5:57 PM To: HttpComponents Project Cc: Moore, Jonathan Subject: File based HTTP cache implementation is feature complete Jon et al I am pretty much done vandalizing your code. In particular I have made some major changes to the SizeLimitedResponseReader class, which can now be used to generate cache entries backed by a file without intermediate content buffering in memory. I think the new API is flexible enough to allow for different caching backends and resource management strategies. I would be great if you could take some time to review the changes, and if you find them acceptable we could move towards the next public release of HttpClient 4.1. Cheers Oleg --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
