Caching system for dynamically created files?
<p>I have a web server that is dynamically creating various reports in several formats (pdf and doc files). The files require a fair amount of CPU to generate, and it is fairly common to have situations where two people are creating the same report with the same input.</p>

<p>Inputs:</p>

<ul>
<li>raw data input as a string (equations, numbers, and
lists of words), arbitrary length, almost 99% will be less than about 200 words </li>
<li>the version of the report creation tool</li>
</ul>

<p>When a user attempts to generate a report, I would like to check to see if a file already exists with the given input, and if so return a link to the file. If the file doesn't already exist, then I would like to generate it as needed.</p>

<ol>
<li><p>What solutions are already out there? I've cached simple http requests before, but the keys were extremely simple (usually database id's)</p></li>
<li><p>If I have to do this myself, what is the best way. The input can be several hundred words, and I was wondering how I should go about transforming the strings into keys sent to the cache.</p>

<p>//entire input, uses too much memory, one to one mapping
cache['one two three four five six seven eight nine ten eleven...']
//short keys
cache['one two'] => 5 results, then I must narrow these down even more</p></li>
<li><p>Is this something that should be done in a database, or is it better done within the web app code (python in my case)</p></li>
</ol>

<p>Thanks you everyone.</p>
