lib/memcache.rb in jruby-memcache-client-1.6.0 vs lib/memcache.rb in jruby-memcache-client-1.6.1

- old
+ new

@@ -1,6 +1,7 @@ require 'java' +require 'base64' require File.dirname(__FILE__) + '/java/java_memcached-release_2.0.1.jar' class MemCache include_class 'com.danga.MemCached.MemCachedClient' @@ -158,11 +159,12 @@ def get(key, raw = false) value = @client.get(make_cache_key(key)) return nil if value.nil? unless raw marshal_bytes = java.lang.String.new(value).getBytes(MARSHALLING_CHARSET) - value = Marshal.load(String.from_java_bytes(marshal_bytes)) + decoded = Base64.decode64(String.from_java_bytes(marshal_bytes)) + value = Marshal.load(decoded) end value end alias :[] :get @@ -177,11 +179,12 @@ values_j.to_a.each {|kv| k,v = kv next if v.nil? unless raw marshal_bytes = java.lang.String.new(v).getBytes(MARSHALLING_CHARSET) - v = Marshal.load(String.from_java_bytes(marshal_bytes)) + decoded = Base64.decode64(String.from_java_bytes(marshal_bytes)) + v = Marshal.load(decoded) end values[k] = v } values end @@ -297,10 +300,11 @@ def expiration(expiry) java.util.Date.new((Time.now.to_i + expiry) * 1000) end def marshal_value(value) - marshal_bytes = Marshal.dump(value).to_java_bytes + encoded = Base64.encode64(Marshal.dump(value)) + marshal_bytes = encoded.to_java_bytes java.lang.String.new(marshal_bytes, MARSHALLING_CHARSET) end end