<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -19,14 +19,17 @@ end
 
 module JokeServer
   include LineBufferedConnection
-  extend InProcessLRUCache
+  
+  def self.cache
+    @cache ||= InProcessLRUCache.new(2)
+  end
 
   def receive_line(line)
     $stats.transaction do
       data, source_transaction_id = line.split(';')
       $stats.set('source_transaction_id', source_transaction_id)
       $stats.measure('job') do
-        result = JokeServer.get(data) do
+        result = JokeServer.cache.get(data) do
           100000.times { Time.now }
           sleep rand
           &quot;KNOCK KNOCK: #{data}\n&quot;</diff>
      <filename>joke_server.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,20 +1,25 @@
-module InProcessLRUCache
-  def get(data)
-    @cache ||= []
-    cache_hit = @cache.detect do |key, value|
-      data == key
-    end
-    if !cache_hit
-      $stats.set('cache_hit', 0)
-
-      result = yield(data)
-      @cache.unshift([data, result])
-      @cache.slice!(2..-1)
-      result
-    else
-      $stats.set('cache_hit', 1)
+class InProcessLRUCache
+  def initialize(max_keys)
+    @max_keys = max_keys
+  end
+  
+  def get(key)
+    @cache ||= {}
+    @lru ||= []
+    
+    @lru &lt;&lt; key
 
-      cache_hit[1]
+    result = @cache[key]
+    $stats.set('cache_hit', !!result)
+    if !result
+      free_least_recently_used_item
+      result = @cache[key] = yield(key) if block_given?
     end
+    result
+  end
+  
+  private
+  def free_least_recently_used_item
+    @cache.delete(@lru.shift) if @cache.size &gt;= @max_keys
   end
 end
\ No newline at end of file</diff>
      <filename>util/in_process_lru_cache.rb</filename>
    </modified>
    <modified>
      <diff>@@ -55,6 +55,8 @@ class Statosaurus
       &quot;-&quot;
     when Float
       &quot;%f&quot; % value
+    when TrueClass, FalseClass
+      value ? '1' : 0
     else
       value.to_s
     end</diff>
      <filename>util/statosaurus.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>6abbb13f2b6491d1993909e012ed6e05fd3845e7</id>
    </parent>
  </parents>
  <author>
    <name>Nick Kallen</name>
    <email>nkallen@yahoo.com</email>
  </author>
  <url>http://github.com/nkallen/gogaruco/commit/fd7b9e466c9646698dd0836e2630f55a3054a1ea</url>
  <id>fd7b9e466c9646698dd0836e2630f55a3054a1ea</id>
  <committed-date>2009-04-20T20:48:27-07:00</committed-date>
  <authored-date>2009-04-20T20:48:27-07:00</authored-date>
  <message>a sensible lru</message>
  <tree>e2c6814b90e2d49332f70616799f02cd65138184</tree>
  <committer>
    <name>Nick Kallen</name>
    <email>nkallen@yahoo.com</email>
  </committer>
</commit>
