myronmarston/vcr — Issue #145: Allow VCR to write to DB instead of disk
Author: chrisle
Created: 2012-03-05 16:21:16+00:00
State: open

*Use case:*
I'm experimenting with the idea of a specialized HTTP request proxy server.

Why? I have a few programs (Rails, PHP, JS) that talk to many APIs: Google Analytics, SEOmoz, Authority Labs, etc.

My objectives that have to do with VCR
1. Minimize the number of calls to any APIs (especially paid subscription ones) by caching requests
2. Control the expiration of the cache by domain name.
eg: SEOmoz expires in 30 days (since it's only updated about once a month). Google Analytics expires in 24 hours.
3. Generate simple reports for myself. Response time, number of calls this month, what program made those calls, etc.

*Why VCR and not a intercepting HTTP proxy server?*
1. I thought it would be simpler to just grab the requested URL and push it back out wrapped in VCR instead of dealing with buffers, TCP, etc.
2. I thought, by storing the caches in a database, I might be simple to query.
3. Also, maybe leveraging the :re_record_interval to control the expiration date. It would save me from having to write my own logic.

*Using the hooks to write to the database instead?*
Yes, but then it would still be writing to disk, wouldn't it? There's no option to disable disk writing, I don't think.