<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,4 +1,4 @@
 A memcached-based throttle - do something after a limit has been
-reached within a certain time. Currently working on the best
-way to &quot;do something&quot; as well as how best to conform to Ruby
-standards for how this project should work. You know, test cases, etc.
+reached within a certain time period.
+
+</diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -32,8 +32,7 @@ describe &quot;a throttle&quot; do
     end
     t.record_event
     sleep(2)
-    violated(@cache.inspect)
-    lambda { t.record_event }.should_not raise_error()
+    t.record_event #}.should_not raise_error()
   end
 
 end</diff>
      <filename>spec/over_time.rb</filename>
    </modified>
    <modified>
      <diff>@@ -75,4 +75,13 @@ describe &quot;a throttle&quot; do
     lambda { t.record_event }.should raise_error('bork')
   end
 
+  it &quot;should fail gracefully when memcache fails&quot; do
+    t = Throttle.create
+    def t.test_threshold(count)
+      raise 'bork'
+    end
+    @cache.simulate_error_on_next
+    lambda { t.record_event }.should_not raise_error()
+  end
+
 end</diff>
      <filename>spec/throttle.rb</filename>
    </modified>
    <modified>
      <diff>@@ -68,8 +68,9 @@ class Throttle
       @@memcache.set(self.gen_throttle_key, self,
         Time.now.to_i + @buckets * @time_per_bucket)
     rescue MemCache::MemCacheError
-      return self #memcache not working, silently ignore
+      #memcache not working, silently ignore
     end
+    return self
   end
 
   def Throttle.retrieve(name)
@@ -97,6 +98,8 @@ class Throttle
     @initial_time ||= Time.now.to_i
   end
 
+protected
+
   ##########################################
   # some functions to determine cache keys
   def Throttle.gen_throttle_key(name)
@@ -154,7 +157,7 @@ class Throttle
     prev_buckets.reject!{|n| n &lt; 0} #won't exist before 0
     prev_buckets.map!{|n| gen_bucket_key(n)} #map to cache keys
     if !prev_buckets.empty?
-      prev_buckets = Array.new(@@memcache.get(*prev_buckets))
+      prev_buckets = [*@@memcache.get(*prev_buckets)]
     end
     prev_buckets.map!{|n| n ||= 0}  #fill w/ 0 if any are missing
     return prev_buckets</diff>
      <filename>throttle.rb</filename>
    </modified>
    <modified>
      <diff>@@ -11,11 +11,15 @@ class Throttle::Simple &lt; Throttle
   end
 end
 
-
 CACHE = MemCache.new 'localhost:11211'
 Throttle.set_memcache(CACHE)
-t = Throttle::Simple.create(:name =&gt; 'baz2', :buckets =&gt; 10, :time_per_bucket =&gt; 1)
-puts t.inspect
-puts t.record_event
-#10.times {t.record_event}
+t = Throttle::Simple.create(
+  :name =&gt; 'example',
+  :buckets =&gt; 10,
+  :time_per_bucket =&gt; 6
+  # throttle over 1min period, broken into 10 intervals
+)
+t.record_event
+puts &quot;All's well until the next line&quot;
+10.times {t.record_event} # -&gt; raises exception
 </diff>
      <filename>tryit.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>c888eb4f4a8158eb8da7831447a630a719f6a6fb</id>
    </parent>
  </parents>
  <author>
    <name>Luke Meyer</name>
    <email>sosiouxme@gmail.com</email>
  </author>
  <url>http://github.com/sosiouxme/throttle/commit/bfed1e4a1d2c13743c4ee3d1295ee28356ba6757</url>
  <id>bfed1e4a1d2c13743c4ee3d1295ee28356ba6757</id>
  <committed-date>2008-10-19T20:47:21-07:00</committed-date>
  <authored-date>2008-10-19T20:47:21-07:00</authored-date>
  <message>fix tests, bug</message>
  <tree>e0474db1767c911d33b9f5d1fdb8c89a5cab92a1</tree>
  <committer>
    <name>Luke Meyer</name>
    <email>sosiouxme@gmail.com</email>
  </committer>
</commit>
