jruby-memcached 0.5.1 → 0.5.2
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/README.md +34 -20
- data/jruby_memcached.gemspec +1 -1
- data/lib/memcached/version.rb +1 -1
- data/spec/timeout_spec.rb +17 -0
- data/src/main/java/com/openfeint/memcached/Rails.java +1 -4
- data/target/spymemcached-ext-0.0.1.jar +0 -0
- metadata +11 -11
data/README.md
CHANGED
@@ -11,45 +11,59 @@ A jruby memcached gem which is compatible with evan's [memcached][0] gem
|
|
11
11
|
Now, in Ruby, require the library and instantiate a Memcached object at
|
12
12
|
a global level:
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
```ruby
|
15
|
+
require 'memcached'
|
16
|
+
$cache = Memcached.new("localhost:11211")
|
17
|
+
```
|
16
18
|
|
17
19
|
Now you can set things and get things:
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
-
|
21
|
+
```ruby
|
22
|
+
value = 'hello'
|
23
|
+
$cache.set 'test', value
|
24
|
+
$cache.get 'test' #=> "hello"
|
25
|
+
```
|
22
26
|
|
23
27
|
You can set with an expiration timeout:
|
24
28
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
+
```ruby
|
30
|
+
value = 'hello'
|
31
|
+
$cache.set 'test', value, 1
|
32
|
+
sleep(2)
|
33
|
+
$cache.get 'test' #=> raises Memcached::NotFound
|
34
|
+
```
|
29
35
|
|
30
36
|
You can get multiple values at once:
|
31
37
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
38
|
+
```ruby
|
39
|
+
value = 'hello'
|
40
|
+
$cache.set 'test', value
|
41
|
+
$cache.set 'test2', value
|
42
|
+
$cache.get ['test', 'test2', 'missing']
|
43
|
+
#=> {"test" => "hello", "test2" => "hello"}
|
44
|
+
```
|
37
45
|
|
38
46
|
You can set a counter and increment it. Note that you must initialize it
|
39
47
|
with an integer, encoded as an unmarshalled ASCII string:
|
40
48
|
|
41
|
-
|
42
|
-
|
43
|
-
|
49
|
+
```ruby
|
50
|
+
$cache.increment 'counter' #=> 1
|
51
|
+
$cache.increment 'counter' #=> 2
|
52
|
+
$cache.get('counter').to_i #=> 2
|
53
|
+
```
|
44
54
|
|
45
55
|
You can get some server stats:
|
46
56
|
|
47
|
-
|
57
|
+
```ruby
|
58
|
+
$cache.stats #=> {..., :bytes_written=>[62], :version=>["1.2.4"] ...}
|
59
|
+
```
|
48
60
|
|
49
61
|
## Rails
|
50
62
|
|
51
|
-
|
52
|
-
|
63
|
+
```ruby
|
64
|
+
# config/environment.rb
|
65
|
+
config.cache_store = Memcached::Rails.new(:servers => ['127.0.0.1'])
|
66
|
+
```
|
53
67
|
|
54
68
|
## Benchmarks
|
55
69
|
|
data/jruby_memcached.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.version = Memcached::VERSION
|
8
8
|
s.authors = ["Richard Huang"]
|
9
9
|
s.email = ["flyerhzm@gmail.com"]
|
10
|
-
s.homepage = "https://github.com/
|
10
|
+
s.homepage = "https://github.com/flyerhzm/jruby-memcached"
|
11
11
|
s.summary = %q{jruby compatible memcached client}
|
12
12
|
s.description = %q{jruby memcacached client which is compatible with memcached gem}
|
13
13
|
|
data/lib/memcached/version.rb
CHANGED
data/spec/timeout_spec.rb
CHANGED
@@ -24,6 +24,23 @@ describe Memcached do
|
|
24
24
|
@memcached.quit
|
25
25
|
end
|
26
26
|
|
27
|
+
describe "Rails" do
|
28
|
+
before(:all) do
|
29
|
+
@timeout_rails = Memcached::Rails.new("127.0.0.1:11211", :timeout => 1, :exception_retry_limit => 0)
|
30
|
+
end
|
31
|
+
|
32
|
+
after(:all) do
|
33
|
+
@timeout_rails.quit
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should return nil when got timeout" do
|
37
|
+
@memcached.set "a-key", "value"
|
38
|
+
while true
|
39
|
+
break if @timeout_rails.get("a-key").nil?
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
27
44
|
it "should set timeout" do
|
28
45
|
lambda {
|
29
46
|
while true
|
@@ -83,10 +83,7 @@ public class Rails extends Memcached {
|
|
83
83
|
try {
|
84
84
|
return super.get(context, new IRubyObject[] { key, notRaw });
|
85
85
|
} catch (RaiseException e) {
|
86
|
-
|
87
|
-
return context.nil;
|
88
|
-
}
|
89
|
-
throw e;
|
86
|
+
return context.nil;
|
90
87
|
}
|
91
88
|
}
|
92
89
|
|
Binary file
|
metadata
CHANGED
@@ -2,27 +2,27 @@
|
|
2
2
|
name: jruby-memcached
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.5.
|
5
|
+
version: 0.5.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Richard Huang
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-02-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
16
|
version_requirements: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: !binary |-
|
21
21
|
MA==
|
22
22
|
none: false
|
23
23
|
requirement: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: !binary |-
|
28
28
|
MA==
|
@@ -33,14 +33,14 @@ dependencies:
|
|
33
33
|
name: mocha
|
34
34
|
version_requirements: !ruby/object:Gem::Requirement
|
35
35
|
requirements:
|
36
|
-
- -
|
36
|
+
- - ">="
|
37
37
|
- !ruby/object:Gem::Version
|
38
38
|
version: !binary |-
|
39
39
|
MA==
|
40
40
|
none: false
|
41
41
|
requirement: !ruby/object:Gem::Requirement
|
42
42
|
requirements:
|
43
|
-
- -
|
43
|
+
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: !binary |-
|
46
46
|
MA==
|
@@ -54,8 +54,8 @@ executables: []
|
|
54
54
|
extensions: []
|
55
55
|
extra_rdoc_files: []
|
56
56
|
files:
|
57
|
-
- .gitignore
|
58
|
-
- .travis.yml
|
57
|
+
- ".gitignore"
|
58
|
+
- ".travis.yml"
|
59
59
|
- CHANGELOG.md
|
60
60
|
- Gemfile
|
61
61
|
- MIT-LICENSE
|
@@ -83,7 +83,7 @@ files:
|
|
83
83
|
- src/main/java/net/spy/memcached/KetamaNodeLocator.java
|
84
84
|
- src/main/java/net/spy/memcached/util/DefaultKetamaNodeLocatorConfiguration.java
|
85
85
|
- target/spymemcached-ext-0.0.1.jar
|
86
|
-
homepage: https://github.com/
|
86
|
+
homepage: https://github.com/flyerhzm/jruby-memcached
|
87
87
|
licenses: []
|
88
88
|
post_install_message:
|
89
89
|
rdoc_options: []
|
@@ -91,7 +91,7 @@ require_paths:
|
|
91
91
|
- lib
|
92
92
|
required_ruby_version: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
segments:
|
97
97
|
- 0
|
@@ -101,7 +101,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
101
101
|
none: false
|
102
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
103
|
requirements:
|
104
|
-
- -
|
104
|
+
- - ">="
|
105
105
|
- !ruby/object:Gem::Version
|
106
106
|
segments:
|
107
107
|
- 0
|