<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -6,11 +6,6 @@ class APICache
   # Ensures that the API is not called more frequently than every +period+ seconds, and times out API requests after +timeout+ seconds.
   #
   class API
-    @query_times = {}
-    class &lt;&lt; self
-      attr_reader :query_times
-    end
-
     # Takes the following options
     #
     # period:: Maximum frequency to call the API
@@ -32,8 +27,8 @@ class APICache
     # be made to the API.
     #
     def queryable?
-      if query_times[@key]
-        if Time.now - query_times[@key] &gt; @period
+      if previously_queried?
+        if Time.now - queried_at &gt; @period
           APICache.logger.debug &quot;Queryable: true - retry_time has passed&quot;
           true
         else
@@ -57,7 +52,7 @@ class APICache
     #
     def get
       APICache.logger.debug &quot;Fetching data from the API&quot;
-      query_times[@key] = Time.now
+      set_queried_at
       Timeout::timeout(@timeout) do
         if @block
           # This should raise APICache::Invalid if it is not correct
@@ -88,8 +83,16 @@ class APICache
       r.header['location'] ? redirecting_get(r.header['location']) : r
     end
 
-    def query_times
-      self.class.query_times
+    def previously_queried?
+      APICache.store.exists?(&quot;#{@key}_queried_at&quot;)
+    end
+    
+    def queried_at
+      APICache.store.get(&quot;#{@key}_queried_at&quot;)
+    end
+    
+    def set_queried_at
+      APICache.store.set(&quot;#{@key}_queried_at&quot;, Time.now)
     end
   end
 end</diff>
      <filename>lib/api_cache/api.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>4cb9905bdaa51270640c6e3d1ac0a59d7f8cba2f</id>
    </parent>
  </parents>
  <author>
    <name>Martyn Loughran</name>
    <email>me@mloughran.com</email>
  </author>
  <url>http://github.com/mloughran/api_cache/commit/e51b438dcf50872d1e0b0b541da1ca0291150741</url>
  <id>e51b438dcf50872d1e0b0b541da1ca0291150741</id>
  <committed-date>2009-05-05T14:28:08-07:00</committed-date>
  <authored-date>2009-05-05T14:16:45-07:00</authored-date>
  <message>Store API query times in the cache store rather than in memory

* Prevents effectively a memory leak
* Behaves correctly in a multi process setup</message>
  <tree>abe2b2f6eb0cc7129a1dd7535c0bbdabcf7f3165</tree>
  <committer>
    <name>Martyn Loughran</name>
    <email>me@mloughran.com</email>
  </committer>
</commit>
