title: using memoize function with underscore.js
body: <p>I am trying to cache the result from an ajax call using <code>memoize</code> function from <code>Underscore.js</code>. I am not sure of my implementation. Also how to retrieve back the cached result data using the key. Below is my implementation:</p>
  
  <p>Javascript code:</p>
  
  <pre><code>var cdata = $http
  .get(HOST_URL + "/v1/report/states")
  .success(function(data) {
      //put the result in the angularJs scope object. 
      $scope.states = data;
  });
  
  //store the result in the cache.
  var cachedResult = _.memoize(
      function() {
          return cdata;
      }, "states");
  </code></pre>
  
  <p>Is my usage of memoize to store the result of ajax is correct. Also once it is put in cache, how to retrieve based on the key. i.e 'states'.</p>