jruby-memcache-client 1.6.1 → 1.7.0

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/.gitignore CHANGED
@@ -1,2 +1,7 @@
1
1
  .DS_Store
2
- nbproject/private
2
+ nbproject/private
3
+ *.swp
4
+ *.orig
5
+ pkg
6
+ *.gem
7
+
data/Rakefile CHANGED
@@ -6,7 +6,8 @@ begin
6
6
  gemspec.email = "fred@fredjean.net"
7
7
  gemspec.homepage = "http://github.com/ikai/jruby-memcache-client"
8
8
  gemspec.description = "A drop in replacement for Ruby's memcache-client."
9
- gemspec.authors = ["Abhi Yerra", "Ikai Lan", "Frederic Jean", "Lennon Day-Reynolds", "slyphon"]
9
+ gemspec.authors = ["Abhi Yerra", "Ikai Lan", "Frederic Jean", "Lennon Day-Reynolds",
10
+ "slyphon", "Brayn Helmkamp", "Travis Tilley"]
10
11
  end
11
12
  rescue LoadError
12
13
  puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 1
3
- :minor: 6
4
- :patch: 1
3
+ :minor: 7
4
+ :patch: 0
@@ -1,15 +1,15 @@
1
1
  # Generated by jeweler
2
- # DO NOT EDIT THIS FILE
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{jruby-memcache-client}
8
- s.version = "1.6.1"
8
+ s.version = "1.7.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Abhi Yerra", "Ikai Lan", "Frederic Jean", "Lennon Day-Reynolds", "slyphon"]
12
- s.date = %q{2009-11-22}
11
+ s.authors = ["Abhi Yerra", "Ikai Lan", "Frederic Jean", "Lennon Day-Reynolds", "slyphon", "Brayn Helmkamp", "Travis Tilley"]
12
+ s.date = %q{2010-01-21}
13
13
  s.description = %q{A drop in replacement for Ruby's memcache-client.}
14
14
  s.email = %q{fred@fredjean.net}
15
15
  s.extra_rdoc_files = [
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
22
22
  "Rakefile",
23
23
  "VERSION.yml",
24
24
  "jruby-memcache-client.gemspec",
25
- "lib/java/java_memcached-release_2.0.1.jar",
25
+ "lib/java/memcached-dev_2.0.2.jar",
26
26
  "lib/memcache.rb",
27
27
  "spec/jruby_memcache_spec.rb"
28
28
  ]
@@ -45,3 +45,4 @@ Gem::Specification.new do |s|
45
45
  else
46
46
  end
47
47
  end
48
+
Binary file
data/lib/memcache.rb CHANGED
@@ -1,13 +1,14 @@
1
1
  require 'java'
2
2
  require 'base64'
3
3
 
4
- require File.dirname(__FILE__) + '/java/java_memcached-release_2.0.1.jar'
4
+ require File.dirname(__FILE__) + '/java/memcached-dev_2.0.2.jar'
5
5
 
6
6
  class MemCache
7
- include_class 'com.danga.MemCached.MemCachedClient'
8
- include_class 'com.danga.MemCached.SockIOPool'
7
+ include_class 'com.meetup.memcached.MemcachedClient'
8
+ include_class 'com.meetup.memcached.SockIOPool'
9
+ include_class 'com.meetup.memcached.Logger'
9
10
 
10
- VERSION = '1.6.0'
11
+ VERSION = '1.7.0'
11
12
 
12
13
  ##
13
14
  # Default options for the cache object.
@@ -16,15 +17,20 @@ class MemCache
16
17
  :namespace => nil,
17
18
  :readonly => false,
18
19
  :multithread => true,
19
- :pool_initial_size => 5,
20
+ :pool_initial_size => 10,
20
21
  :pool_min_size => 5,
21
- :pool_max_size => 250,
22
- :pool_max_idle => (1000 * 60 * 60 * 6),
23
- :pool_maintenance_thread_sleep => 30,
22
+ :pool_max_size => 100,
23
+ :pool_max_idle => (1000 * 60 * 5),
24
+ :pool_max_busy => (1000 * 30),
25
+ :pool_maintenance_thread_sleep => (1000 * 30),
26
+ :pool_socket_timeout => (1000 * 3),
27
+ :pool_socket_connect_timeout => (1000 * 3),
28
+ :pool_use_alive => false,
29
+ :pool_use_failover => true,
30
+ :pool_use_failback => true,
24
31
  :pool_use_nagle => false,
25
- :pool_socket_timeout => 3000,
26
- :pool_socket_connect_timeout => 3000,
27
- :pool_name => 'default'
32
+ :pool_name => 'default',
33
+ :log_level => 2
28
34
  }
29
35
 
30
36
  ## CHARSET for Marshalling
@@ -85,8 +91,9 @@ class MemCache
85
91
  @pool_name = opts[:pool_name] || opts["pool_name"]
86
92
  @readonly = opts[:readonly] || opts["readonly"]
87
93
 
88
- @client = MemCachedClient.new(@pool_name)
94
+ @client = MemcachedClient.new(@pool_name)
89
95
 
96
+ @client.error_handler = opts[:error_handler] if opts[:error_handler]
90
97
  @client.primitiveAsString = true
91
98
  @client.sanitizeKeys = false
92
99
 
@@ -94,39 +101,35 @@ class MemCache
94
101
 
95
102
  @pool = SockIOPool.getInstance(@pool_name)
96
103
  unless @pool.initialized?
97
- # // set the servers and the weights
98
104
  @pool.servers = @servers.to_java(:string)
99
105
  @pool.weights = weights.to_java(:Integer)
100
106
 
101
- # // set some basic pool settings
102
- # // 5 initial, 5 min, and 250 max conns
103
- # // and set the max idle time for a conn
104
- # // to 6 hours
105
107
  @pool.initConn = opts[:pool_initial_size]
106
108
  @pool.minConn = opts[:pool_min_size]
107
109
  @pool.maxConn = opts[:pool_max_size]
108
- @pool.maxIdle = opts[:pool_max_idle]
109
110
 
110
- # // set the sleep for the maint thread
111
- # // it will wake up every x seconds and
112
- # // maintain the pool size
111
+ @pool.maxIdle = opts[:pool_max_idle]
112
+ @pool.maxBusyTime = opts[:pool_max_busy]
113
113
  @pool.maintSleep = opts[:pool_maintenance_thread_sleep]
114
- #
115
- # // set some TCP settings
116
- # // disable nagle
117
- # // set the read timeout to 3 secs
118
- # // and don't set a connect timeout
119
- @pool.nagle = opts[:pool_use_nagle]
120
114
  @pool.socketTO = opts[:pool_socket_timeout]
121
115
  @pool.socketConnectTO = opts[:pool_socket_connect_timeout]
122
- @pool.aliveCheck = true
123
- @pool.initialize__method
116
+
117
+ @pool.failover = opts[:pool_use_failover]
118
+ @pool.failback = opts[:pool_use_failback]
119
+ @pool.aliveCheck = opts[:pool_use_alive]
120
+ @pool.nagle = opts[:pool_use_nagle]
121
+
122
+ # __method methods have been removed in jruby 1.5
123
+ @pool.java_send :initialize rescue @pool.initialize__method
124
124
  end
125
+
126
+ Logger.getLogger('com.meetup.memcached.MemcachedClient').setLevel(opts[:log_level])
127
+ Logger.getLogger('com.meetup.memcached.SockIOPool').setLevel(opts[:log_level])
125
128
  end
126
129
 
127
130
  def reset
128
131
  @pool.shut_down
129
- @pool.initialize__method
132
+ @pool.java_send :initialize rescue @pool.initialize__method
130
133
  end
131
134
 
132
135
  ##
@@ -2,13 +2,15 @@ require 'java'
2
2
  require File.dirname(__FILE__) + '/../lib/memcache'
3
3
 
4
4
  describe MemCache do
5
- before(:all) do
5
+ before :all do
6
6
  @server = "127.0.0.1:11211"
7
7
  @client = MemCache.new @server
8
- @client.flush_all
9
8
  end
10
9
 
11
- after(:each) do
10
+ before :each do
11
+ @client.flush_all
12
+ end
13
+ after :each do
12
14
  @client.flush_all
13
15
  end
14
16
 
@@ -36,6 +38,15 @@ describe MemCache do
36
38
  @client = MemCache.new([@server], :pool_name => 'new_pool')
37
39
  @client.pool_name.should == 'new_pool'
38
40
  end
41
+
42
+ it "should work with an error handler" do
43
+ include_class 'com.meetup.memcached.MemcachedClient'
44
+ java_memcache_client = mock.as_null_object
45
+ MemcachedClient.stub!(:new => java_memcache_client)
46
+ error_handler = Object.new
47
+ java_memcache_client.should_receive(:error_handler=).with(error_handler)
48
+ @client = MemCache.new([@server], :error_handler => error_handler)
49
+ end
39
50
  end
40
51
 
41
52
  describe "namespacing" do
@@ -189,7 +200,7 @@ describe MemCache do
189
200
  @client.set('obj', obj)
190
201
  @client.get('obj').should == obj
191
202
  end
192
-
203
+
193
204
  it %[should work with binary blobs] do
194
205
  # this test fails w/o the Base64 encoding step
195
206
  blob = "\377\330\377\340\000\020JFIF\000\001\001\000\000\001\000\001\000\000\377"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jruby-memcache-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.1
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abhi Yerra
@@ -9,11 +9,13 @@ authors:
9
9
  - Frederic Jean
10
10
  - Lennon Day-Reynolds
11
11
  - slyphon
12
+ - Brayn Helmkamp
13
+ - Travis Tilley
12
14
  autorequire:
13
15
  bindir: bin
14
16
  cert_chain: []
15
17
 
16
- date: 2009-11-22 00:00:00 -07:00
18
+ date: 2010-01-21 00:00:00 -07:00
17
19
  default_executable:
18
20
  dependencies: []
19
21
 
@@ -32,7 +34,7 @@ files:
32
34
  - Rakefile
33
35
  - VERSION.yml
34
36
  - jruby-memcache-client.gemspec
35
- - lib/java/java_memcached-release_2.0.1.jar
37
+ - lib/java/memcached-dev_2.0.2.jar
36
38
  - lib/memcache.rb
37
39
  - spec/jruby_memcache_spec.rb
38
40
  has_rdoc: true