spymemcached 0.2.0-java → 0.2.1-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
data/lib/spymemcached.rb CHANGED
@@ -18,7 +18,7 @@ class Spymemcached
18
18
 
19
19
  def get(key, marshal = true)
20
20
  value = @client.get(key)
21
- marshal && value ? Marshal.load(value) : value
21
+ marshal && value ? marshal_load(value) : value
22
22
  end
23
23
 
24
24
  def incr(key, by = 1)
@@ -38,7 +38,7 @@ class Spymemcached
38
38
  end
39
39
 
40
40
  def multiget(keys, marshal = true)
41
- Hash[*@client.getBulk(*keys).map { |k,v| [k, marshal ? Marshal.load(v) : v] }.flatten]
41
+ Hash[*@client.getBulk(*keys).map { |k,v| [k, marshal ? marshal_load(v) : v] }.flatten]
42
42
  end
43
43
 
44
44
  def add(key, value, expiration = 0, marshal = true)
@@ -55,6 +55,10 @@ class Spymemcached
55
55
 
56
56
  private
57
57
  def marshal(value, marshal)
58
- marshal ? Marshal.dump(value) : value.to_s
58
+ marshal ? Marshal.dump(value).to_java_bytes : value.to_s
59
+ end
60
+
61
+ def marshal_load(value)
62
+ Marshal.load(String.from_java_bytes(value))
59
63
  end
60
64
  end
@@ -1,4 +1,5 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+ require "action_view"
2
3
 
3
4
  describe Spymemcached do
4
5
  before do
@@ -115,4 +116,14 @@ describe Spymemcached do
115
116
  @cache.add("a", {:a => "b"}, 0, false)
116
117
  @cache.get("a", false).should == {:a => "b"}.to_s
117
118
  end
119
+
120
+ # not sure exactly why, but ActionView::SafeBuffer
121
+ # is the only repeatable instance of this bug that
122
+ # I can find
123
+ it "supports marshalling ActionView::SafeBuffers" do
124
+ s = ActionView::SafeBuffer.new "<div class=\"story_2 clearfix\">\n <a href=\"/users/4\"><img alt=\"\" class=\"\" height=\"35\" src=\"http:///avatar_missing_35x35.gif\" title=\"\" width=\"35\" /></a>"
125
+ @cache.set("a", s)
126
+ @cache.get("a").should == s
127
+ @cache.multiget(["a"]).should == {"a" => s}
128
+ end
118
129
  end
data/spymemcached.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{spymemcached}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
  s.platform = %q{java}
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 0
9
- version: 0.2.0
8
+ - 1
9
+ version: 0.2.1
10
10
  platform: java
11
11
  authors:
12
12
  - James Golick