<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1 +1,2 @@
+require 'digest/sha1'
 File.expand_path(File.dirname(__FILE__) + &quot;/lib/memcached_protected&quot;)
\ No newline at end of file</diff>
      <filename>init.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,37 +1,19 @@
 class MemcachedProtected::ProtectedAccess
   
-  MAX_KEY_SIZE = 247
-  
   class &lt;&lt; self
 
     def read(key)
-      if valid_key?(key)
-        Rails.original_cache.read(key) 
-      else
-        write_error key
-        nil
-      end
+      Rails.original_cache.read(generate_key(key)) 
     end
     
     def write(key, content)
-      if valid_key?(key)
-        Rails.original_cache.write(key, content)
-      else
-        write_error key
-      end
+      Rails.original_cache.write(generate_key(key), content)
     end
     
     private
     
-      def write_error(key)
-        Rails.logger.error &quot;-&quot; * 80
-        Rails.logger.error &quot;Memcache key is too long.&quot;
-        Rails.logger.error &quot;key size: #{key.size}&quot;
-        Rails.logger.error &quot;key: #{key}&quot;
-      end
-    
-      def valid_key?(key)
-        key.kind_of?(String) &amp;&amp; key.size &lt;= MAX_KEY_SIZE 
+      def generate_key(key)
+        Digest::SHA1.hexdigest(key)
       end
     
   end</diff>
      <filename>lib/memcached_protected/protected_access.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,57 +4,19 @@ describe MemcachedProtected::ProtectedAccess do
   
   describe &quot;.read&quot; do
 
-    it &quot;should log and return nil if key &gt; 250&quot; do
-      Rails.original_cache.should_receive(:read).never
-      Rails.logger.should_receive(:error).with(&quot;-&quot; * 80)
-      Rails.logger.should_receive(:error).with(&quot;Memcache key is too long.&quot;)
-      Rails.logger.should_receive(:error).with(&quot;key size: 251&quot;)
-      Rails.logger.should_receive(:error).with(&quot;key: #{&quot;*&quot;*251}&quot;)
-      MemcachedProtected::ProtectedAccess.read(&quot;*&quot;*251).should be_nil
-    end
-    
-    def verify_valid_key(key)
-      Rails.original_cache.should_receive(:read).with(key).and_return(&quot;fetched from cache&quot;)
-      Rails.logger.should_receive(:error).never
-      MemcachedProtected::ProtectedAccess.read(key).should == &quot;fetched from cache&quot;
-    end
-
-    it &quot;should delegate to Rails.cache.read if key = 250&quot; do
-      verify_valid_key &quot;*&quot;*250
-    end
-
-    it &quot;should delegate to Rails.cache.read if key &lt; 250&quot; do
-      verify_valid_key &quot;*&quot;*249
+    it &quot;should generate a protected key&quot; do
+      Rails.original_cache.should_receive(:read).with(&quot;58efdc201e7a8f6f621d47146beaa3d6186339b2&quot;)
+      MemcachedProtected::ProtectedAccess.read(&quot;very big key&quot;*251).should be_nil
     end
 
   end
   
   describe &quot;.write&quot; do
 
-    it &quot;should log when key &gt; 250&quot; do
-      Rails.original_cache.should_receive(:write).never
-      Rails.logger.should_receive(:error).with(&quot;-&quot; * 80)
-      Rails.logger.should_receive(:error).with(&quot;Memcache key is too long.&quot;)
-      Rails.logger.should_receive(:error).with(&quot;key size: 251&quot;)
-      Rails.logger.should_receive(:error).with(&quot;key: #{&quot;*&quot;*251}&quot;)
-      MemcachedProtected::ProtectedAccess.write(&quot;*&quot;*251, &quot;content&quot;)
-    end
-    
-    def write_valid_key(key)
-      Rails.original_cache.should_receive(:write).with(key, &quot;content&quot;)
-      Rails.logger.should_receive(:error).never
-      MemcachedProtected::ProtectedAccess.write(key, &quot;content&quot;)
-    end
-    
-    
-    it &quot;should delegate to Rails.cache.write if key = 250&quot; do
-      write_valid_key &quot;*&quot;*249
-    end
-
-    it &quot;should delegate to Rails.cache.write if key = 250&quot; do
-      write_valid_key &quot;*&quot;*249
+    it &quot;should generate a protected key&quot; do
+      Rails.original_cache.should_receive(:write).with(&quot;58efdc201e7a8f6f621d47146beaa3d6186339b2&quot;, &quot;content&quot;)
+      MemcachedProtected::ProtectedAccess.write(&quot;very big key&quot;*251, &quot;content&quot;).should be_nil
     end
-    
 
   end
   </diff>
      <filename>spec/memcached_protected/protected_access_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>bae97de589257b0d6730b6e532f290cbb5379753</id>
    </parent>
  </parents>
  <author>
    <name>Tapaj&#243;s</name>
    <email>tapajos@gmail.com</email>
  </author>
  <url>http://github.com/tapajos/memcached_protected/commit/6417603c545ababf4d8f475de633fd3653fb1f83</url>
  <id>6417603c545ababf4d8f475de633fd3653fb1f83</id>
  <committed-date>2009-07-26T19:46:44-07:00</committed-date>
  <authored-date>2009-07-19T17:49:39-07:00</authored-date>
  <message>Changing to use Digest</message>
  <tree>5508a213b1ea054d92ae3a11bdbe4c4ce46bb0bc</tree>
  <committer>
    <name>Tapaj&#243;s</name>
    <email>tapajos@gmail.com</email>
  </committer>
</commit>
