frostwire/frostwire-common — pull request #8 by gubatron (2014-12-14 02:26:52+00:00)
Title: Cache torrents by infohash, cache failed url requests temporarily.

### Cache by infohash
By caching results by infohash, we can avoid performing searches not only in the future, but also reduce the HTTP load on search engines and the load on the DHT, since a search may yield the same info hashes from different torrent engines.

I measured the improvement with counters, and it's not dramatic but it does happen often, specially in subsequent/related searches.

Collectively, I believe tihs will be a considerable relief for search engines and the DHT nodes.

### Failed Requests

Surprisingly, my measurements showed that this is where the most impact was felt. Turns out we have a lot of failed torrent fetching requests that if we don't try them again on the next searches, doesn't really affect the quality of the search results, yet saves FrostWire a lot of unnecessary effort.

I'm basically caching all the failed requests by prepending "failed" to the key (url) on the cache.
The value I put in the cache is the timestamp of the event. This is used in the future once 15 minutes have passed to clear the offending URL, as the crawl may have failed for reasons related to network connectivity or the user's particular environment, and not because of a real 404.