summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--memcache.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/memcache.py b/memcache.py
index df0be58..2d7f666 100644
--- a/memcache.py
+++ b/memcache.py
@@ -622,18 +622,21 @@ class Client(local):
pickler.persistent_id = self.persistent_id
pickler.dump(val)
val = file.getvalue()
- # silently do not store if value length exceeds maximum
- if len(val) >= SERVER_MAX_VALUE_LENGTH: return(0)
lv = len(val)
- # We should try to compress if min_compress_len > 0 and we could import zlib and this string is longer than our min threshold.
+ # We should try to compress if min_compress_len > 0 and we could
+ # import zlib and this string is longer than our min threshold.
if min_compress_len and _supports_compress and lv > min_compress_len:
comp_val = compress(val)
- #Only retain the result if the compression result is smaller than the original.
+ # Only retain the result if the compression result is smaller
+ # than the original.
if len(comp_val) < lv:
flags |= Client._FLAG_COMPRESSED
val = comp_val
+ # silently do not store if value length exceeds maximum
+ if len(val) >= SERVER_MAX_VALUE_LENGTH: return(0)
+
return (flags, len(val), val)
def _set(self, cmd, key, val, time, min_compress_len = 0):