Skip to content
Browse files

fix ClassCastException from Long to RubyFixnum

  • Loading branch information...
1 parent 08f9884 commit 334bc65e5adab5e8a2290c784d78e64f97b0b3e0 @flyerhzm flyerhzm committed Aug 17, 2012
View
7 spec/rails_spec.rb
@@ -86,6 +86,13 @@
@memcached.write("key", "value").should be_true
@memcached.read("key").should == "value"
end
+
+ it "should expire" do
+ @memcached.write("key", "value", :expires_in => 1)
+ @memcached.read("key").should == "value"
+ sleep 1
+ @memcached.read("key").should be_nil
+ end
end
context "fetch" do
View
6 src/main/java/com/openfeint/memcached/Rails.java
@@ -214,9 +214,11 @@ private RubyFixnum getTTL(ThreadContext context, IRubyObject[] args, int index)
} else if (args[index] instanceof RubyHash) {
RubyHash options = (RubyHash) args[index];
if (options.containsKey(ruby.newSymbol("ttl"))) {
- return (RubyFixnum) options.get(ruby.newSymbol("ttl"));
+ Long ttl = (Long) options.get(ruby.newSymbol("ttl"));
+ return ruby.newFixnum(ttl);
} else if (options.containsKey(ruby.newSymbol("expires_in"))) {
- return (RubyFixnum) options.get(ruby.newSymbol("expires_in"));
+ Long expiresIn = (Long) options.get(ruby.newSymbol("expires_in"));
+ return ruby.newFixnum(expiresIn);
}
}
}
View
BIN target/spymemcached-ext-0.0.1.jar
Binary file not shown.

0 comments on commit 334bc65

Please sign in to comment.
Something went wrong with that request. Please try again.