<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -10,7 +10,6 @@ class ratelimit(object):
     requests = 20 # Number of allowed requests in that time period
     
     prefix = 'rl-' # Prefix for memcache key
-    expire_after = (minutes + 1) * 60
     
     def __init__(self, **options):
         for key, value in options.items():
@@ -44,10 +43,10 @@ class ratelimit(object):
         # memcache is only backend that can increment atomically
         try:
             # add first, to ensure the key exists
-            cache._cache.add(key, '0', time=self.expire_after)
+            cache._cache.add(key, '0', time=self.expire_after())
             cache._cache.incr(key)
         except AttributeError:
-            cache.set(key, cache.get(key, 0) + 1, self.expire_after)
+            cache.set(key, cache.get(key, 0) + 1, self.expire_after())
     
     def should_ratelimit(self, request):
         return True
@@ -80,7 +79,10 @@ class ratelimit(object):
     def disallowed(self, request):
         &quot;Over-ride this method if you want to log incidents&quot;
         return HttpResponseForbidden('Rate limit exceeded')
-
+    
+    def expire_after(self):
+        &quot;Used for setting the memcached cache expiry&quot;
+        return (self.minutes + 1) * 60
 
 class ratelimit_post(ratelimit):
     &quot;Rate limit POSTs - can be used to protect a login form&quot;
@@ -97,5 +99,3 @@ class ratelimit_post(ratelimit):
             extra += '-' + value
         return extra
 
-        
-    
\ No newline at end of file</diff>
      <filename>ratelimitcache.py</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>7f52ce1179ad5f01d7b5e918a65b5edb7f2caa84</id>
    </parent>
  </parents>
  <author>
    <name>Simon Willison</name>
    <email>simon@simonwillison.net</email>
  </author>
  <url>http://github.com/simonw/ratelimitcache/commit/591db0eb3a7270741a2032d3d8ededdec454e4f4</url>
  <id>591db0eb3a7270741a2032d3d8ededdec454e4f4</id>
  <committed-date>2009-09-24T07:17:36-07:00</committed-date>
  <authored-date>2009-09-24T07:17:36-07:00</authored-date>
  <message>expire_after is now a method, not a property - which means it always takes the current value for self.minutes in to account. Thanks Matthew Somerville.</message>
  <tree>056fe9f634c2030b21457721e00535aa73d67c24</tree>
  <committer>
    <name>Simon Willison</name>
    <email>simon@simonwillison.net</email>
  </committer>
</commit>
