diff --git a/README.txt b/README.txt
index 5929838..925d2c1 100644
--- a/README.txt
+++ b/README.txt
@@ -123,6 +123,9 @@ $conf = array(
   'memcache_key_prefix' => 'something_unique',
 );
 
+Note that the prefix, key and bin name must be less than 250 characters in
+total. Keys longer than this will be hashed instead.
+
 ## SESSIONS ##
 
 NOTE: Session.inc is not yet ported to Drupal 7 and is not recommended for use
diff --git a/dmemcache.inc b/dmemcache.inc
index 5b0629a..ca5f4ba 100644
--- a/dmemcache.inc
+++ b/dmemcache.inc
@@ -453,7 +453,7 @@ function dmemcache_key($key, $bin = 'cache') {
   // a longer key, hash it with sha1 which will shrink the key down to 40 bytes
   // while still keeping it unique.
   if (strlen($full_key) > 250) {
-    $full_key = $prefix . $bin . '-' . sha1($key);
+    $full_key = urlencode(sha1($prefix . $bin . '-' . $key));
   }
 
   return $full_key;
