Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Properly marshal objects for =[] and [] methods.

  • Loading branch information...
commit 380cc4ca5775e5187c32c6c21ed900addcc008fc 1 parent cfcc7c6
Taylor Weibley authored
Showing with 5 additions and 3 deletions.
  1. +5 −3 lib/redis.rb
View
8 lib/redis.rb
@@ -33,8 +33,9 @@ def initialize(opts={})
#
# Return value: status code reply
def []=(key, val)
+ val = Marshal.dump(val)
timeout_retry(10, 3){
- write "SET #{key} #{val.to_s.size}\r\n#{val}\r\n"
+ write "SET #{key} #{val.size}\r\n#{val}\r\n"
status_code_reply
}
end
@@ -49,8 +50,9 @@ def []=(key, val)
#
# 1 if the key was set 0 if the key was not set
def set_unless_exists(key, val)
+ val = Marshal.dump(val)
timeout_retry(10, 3){
- write "SETNX #{key} #{val.to_s.size}\r\n#{val}\r\n"
+ write "SETNX #{key} #{val.size}\r\n#{val}\r\n"
integer_reply == 1
}
end
@@ -65,7 +67,7 @@ def set_unless_exists(key, val)
def [](key)
timeout_retry(10, 3){
write "GET #{key}\r\n"
- bulk_reply
+ Marshal.load(bulk_reply)
}
end
Please sign in to comment.
Something went wrong with that request. Please try again.