jruby-memcached 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.5.4 (May 14, 2013)
2
+
3
+ Features:
4
+
5
+ - add Memcached#active? method
6
+
1
7
  ## 0.5.3 (Apr 1, 2013)
2
8
 
3
9
  Bugfixes:
@@ -1,3 +1,3 @@
1
1
  class Memcached
2
- VERSION = "0.5.3"
2
+ VERSION = "0.5.4"
3
3
  end
@@ -231,5 +231,17 @@ describe Memcached do
231
231
  end
232
232
  end
233
233
  end
234
+
235
+ context "active?" do
236
+ it "should be true if has available servers" do
237
+ expect(@memcached.active?).to eq(true)
238
+ end
239
+
240
+ it "should be false if hasn't available servers" do
241
+ @memcached_bad = Memcached.new(["127.0.0.1:22121"])
242
+ expect(@memcached_bad.active?).to eq(false)
243
+ @memcached_bad.quit
244
+ end
245
+ end
234
246
  end
235
247
  end
@@ -32,6 +32,7 @@ import java.util.List;
32
32
  import java.util.HashMap;
33
33
  import java.util.Map;
34
34
  import java.util.concurrent.ExecutionException;
35
+ import java.util.Collection;
35
36
 
36
37
  @JRubyClass(name = "Memcached")
37
38
  public class Memcached extends RubyObject {
@@ -376,6 +377,13 @@ public class Memcached extends RubyObject {
376
377
  return context.nil;
377
378
  }
378
379
 
380
+ @JRubyMethod(name = "active?")
381
+ public IRubyObject isActive(ThreadContext context) {
382
+ Ruby ruby = context.getRuntime();
383
+ Collection addresses = client.getAvailableServers();
384
+ return ruby.newBoolean(!addresses.isEmpty());
385
+ }
386
+
379
387
  protected int getDefaultTTL() {
380
388
  return ttl;
381
389
  }
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: jruby-memcached
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.5.3
5
+ version: 0.5.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Richard Huang
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-01 00:00:00.000000000 Z
12
+ date: 2013-05-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec