title: How to Cache flask function results
body: <p>I want to cache the results of a flask function which is called by an event on my Website:</p>
  
  <p>This is the function on flask: </p>
  
  <pre class="lang-py prettyprint-override"><code>@app.route('/request_hourly_prediction')
  def request_hourly_prediction():
      number = request.args.get('s_num')
  
      # do some stuff...
      # return jsonify(results)
  
  </code></pre>
  
  <p>And this is how is called by the website:</p>
  
  <pre><code>function func3(x) {
      $.getJSON(ROOT + '/request_hourly_prediction?s_num=' + x, null, function(data1) {
      // do stuff...
  }
  </code></pre>
  
  <p>As you can see, I pass an argument to the function using <code>request.args.get('s_num')</code> I want to cache the results of the function based on the argument I pass: I tried with <code>@lru_cache(maxsize=32)</code> but it cache the function result regardless of the argument given.</p>
  
  <p>I also saw some decorator functions that holds the results based on the arguments passed to a python function but the problem in this case is that I'm not actually passing any arguments inside the function call but I'm getting them from inside the function using <code>request.args.get('s_num')</code>.</p>