memcached 0.18.0 → 0.19.pre
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/CHANGELOG +3 -1
- data/Manifest +2 -0
- data/README +2 -2
- data/ext/extconf.rb +19 -11
- data/ext/rlibmemcached.i +19 -1
- data/ext/rlibmemcached_wrap.c +284 -53
- data/ext/sasl.patch +29283 -0
- data/lib/memcached.rb +1 -0
- data/lib/memcached/auth.rb +16 -0
- data/lib/memcached/memcached.rb +112 -49
- data/lib/memcached/rails.rb +2 -7
- data/memcached.gemspec +4 -4
- data/test/unit/binding_test.rb +1 -1
- data/test/unit/memcached_test.rb +22 -3
- data/test/unit/rails_test.rb +8 -1
- metadata +15 -5
- metadata.gz.sig +0 -0
data/lib/memcached.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
class Memcached
|
2
|
+
def destroy_credentials
|
3
|
+
if options[:credentials] != nil
|
4
|
+
check_return_code(Lib.memcached_destroy_sasl_auth_data(@struct))
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
def set_credentials
|
9
|
+
# If credentials aren't provided, try to get them from the environment
|
10
|
+
if options[:credentials] != nil
|
11
|
+
username, password = options[:credentials]
|
12
|
+
check_return_code(Lib.memcached_set_sasl_auth_data(@struct, username, password))
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
data/lib/memcached/memcached.rb
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
The Memcached client class.
|
4
4
|
=end
|
5
5
|
class Memcached
|
6
|
-
|
7
6
|
FLAGS = 0x0
|
8
7
|
|
9
8
|
DEFAULTS = {
|
@@ -20,8 +19,9 @@ class Memcached
|
|
20
19
|
:timeout => 0.25,
|
21
20
|
:rcv_timeout => nil,
|
22
21
|
:poll_timeout => nil,
|
23
|
-
:connect_timeout =>
|
24
|
-
:prefix_key =>
|
22
|
+
:connect_timeout => 4,
|
23
|
+
:prefix_key => '',
|
24
|
+
:prefix_delimiter => '',
|
25
25
|
:hash_with_prefix_key => true,
|
26
26
|
:default_ttl => 604800,
|
27
27
|
:default_weight => 8,
|
@@ -30,7 +30,8 @@ class Memcached
|
|
30
30
|
:server_failure_limit => 2,
|
31
31
|
:verify_key => true,
|
32
32
|
:use_udp => false,
|
33
|
-
:binary_protocol => false
|
33
|
+
:binary_protocol => false,
|
34
|
+
:credentials => nil
|
34
35
|
}
|
35
36
|
|
36
37
|
#:stopdoc:
|
@@ -52,7 +53,8 @@ Weights only affect Ketama hashing. If you use Ketama hashing and don't specify
|
|
52
53
|
|
53
54
|
Valid option parameters are:
|
54
55
|
|
55
|
-
<tt>:prefix_key</tt>:: A string to prepend to every key, for namespacing. Max length is 127.
|
56
|
+
<tt>:prefix_key</tt>:: A string to prepend to every key, for namespacing. Max length is 127. Defaults to the empty string.
|
57
|
+
<tt>:prefix_delimiter</tt>:: A character to postpend to the prefix key. Defaults to the empty string.
|
56
58
|
<tt>:hash</tt>:: The name of a hash function to use. Possible values are: <tt>:crc</tt>, <tt>:default</tt>, <tt>:fnv1_32</tt>, <tt>:fnv1_64</tt>, <tt>:fnv1a_32</tt>, <tt>:fnv1a_64</tt>, <tt>:hsieh</tt>, <tt>:md5</tt>, and <tt>:murmur</tt>. <tt>:fnv1_32</tt> is fast and well known, and is the default. Use <tt>:md5</tt> for compatibility with other ketama clients.
|
57
59
|
<tt>:distribution</tt>:: Either <tt>:modula</tt>, <tt>:consistent_ketama</tt>, <tt>:consistent_wheel</tt>, or <tt>:ketama</tt>. Defaults to <tt>:ketama</tt>.
|
58
60
|
<tt>:server_failure_limit</tt>:: How many consecutive failures to allow before marking a host as dead. Has no effect unless <tt>:retry_timeout</tt> is also set.
|
@@ -78,15 +80,28 @@ Please note that when pipelining is enabled, setter and deleter methods do not r
|
|
78
80
|
|
79
81
|
=end
|
80
82
|
|
81
|
-
def initialize(servers =
|
82
|
-
@struct = Lib
|
83
|
-
Lib.memcached_create(@struct)
|
83
|
+
def initialize(servers = nil, opts = {})
|
84
|
+
@struct = Lib.memcached_create(nil)
|
84
85
|
|
85
86
|
# Merge option defaults and discard meaningless keys
|
86
87
|
@options = DEFAULTS.merge(opts)
|
87
88
|
@options.delete_if { |k,v| not DEFAULTS.keys.include? k }
|
88
89
|
@default_ttl = options[:default_ttl]
|
89
90
|
|
91
|
+
if servers == nil
|
92
|
+
if ENV.key?("MEMCACHE_SERVERS")
|
93
|
+
servers = ENV["MEMCACHE_SERVERS"].split(",").map do | s | s.strip end
|
94
|
+
else
|
95
|
+
servers = "127.0.0.1:11211"
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
if options[:credentials] == nil && ENV.key?("MEMCACHE_USERNAME") && ENV.key?("MEMCACHE_PASSWORD")
|
100
|
+
options[:credentials] = [ENV["MEMCACHE_USERNAME"], ENV["MEMCACHE_PASSWORD"]]
|
101
|
+
end
|
102
|
+
|
103
|
+
options[:binary_protocol] = true if options[:credentials] != nil
|
104
|
+
|
90
105
|
# Force :buffer_requests to use :no_block
|
91
106
|
# XXX Deleting the :no_block key should also work, but libmemcached doesn't seem to set it
|
92
107
|
# consistently
|
@@ -95,9 +110,6 @@ Please note that when pipelining is enabled, setter and deleter methods do not r
|
|
95
110
|
# Disallow weights without ketama
|
96
111
|
options.delete(:ketama_weighted) if options[:distribution] != :consistent_ketama
|
97
112
|
|
98
|
-
# Legacy accessor
|
99
|
-
options[:prefix_key] = options.delete(:namespace) if options[:namespace]
|
100
|
-
|
101
113
|
# Disallow :sort_hosts with consistent hashing
|
102
114
|
if options[:sort_hosts] and options[:distribution] == :consistent
|
103
115
|
raise ArgumentError, ":sort_hosts defeats :consistent hashing"
|
@@ -107,9 +119,12 @@ Please note that when pipelining is enabled, setter and deleter methods do not r
|
|
107
119
|
options[:rcv_timeout] ||= options[:timeout] || 0
|
108
120
|
options[:poll_timeout] ||= options[:timeout] || 0
|
109
121
|
|
110
|
-
# Set the
|
122
|
+
# Set the prefix key. Support the legacy name.
|
123
|
+
set_prefix_key(options.delete(:prefix_key) || options.delete(:namespace))
|
124
|
+
|
125
|
+
# Set the behaviors and credentials on the struct
|
111
126
|
set_behaviors
|
112
|
-
|
127
|
+
set_credentials
|
113
128
|
|
114
129
|
# Freeze the hash
|
115
130
|
options.freeze
|
@@ -120,9 +135,9 @@ Please note that when pipelining is enabled, setter and deleter methods do not r
|
|
120
135
|
# Not found exceptions
|
121
136
|
unless options[:show_backtraces]
|
122
137
|
@not_found = NotFound.new
|
123
|
-
@not_found.no_backtrace = true
|
138
|
+
@not_found.no_backtrace = true
|
124
139
|
@not_stored = NotStored.new
|
125
|
-
@not_stored.no_backtrace = true
|
140
|
+
@not_stored.no_backtrace = true
|
126
141
|
end
|
127
142
|
end
|
128
143
|
|
@@ -131,21 +146,23 @@ Please note that when pipelining is enabled, setter and deleter methods do not r
|
|
131
146
|
def set_servers(servers)
|
132
147
|
Array(servers).each_with_index do |server, index|
|
133
148
|
# Socket
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
149
|
+
check_return_code(
|
150
|
+
if server.is_a?(String) and File.socket?(server)
|
151
|
+
args = [@struct, server, options[:default_weight].to_i]
|
152
|
+
Lib.memcached_server_add_unix_socket_with_weight(*args)
|
153
|
+
# Network
|
154
|
+
elsif server.is_a?(String) and server =~ /^[\w\d\.-]+(:\d{1,5}){0,2}$/
|
155
|
+
host, port, weight = server.split(":")
|
156
|
+
args = [@struct, host, port.to_i, (weight || options[:default_weight]).to_i]
|
157
|
+
if options[:use_udp]
|
158
|
+
Lib.memcached_server_add_udp_with_weight(*args)
|
159
|
+
else
|
160
|
+
Lib.memcached_server_add_with_weight(*args)
|
161
|
+
end
|
143
162
|
else
|
144
|
-
|
163
|
+
raise ArgumentError, "Servers must be either in the format 'host:port[:weight]' (e.g., 'localhost:11211' or 'localhost:11211:10') for a network server, or a valid path to a Unix domain socket (e.g., /var/run/memcached)."
|
145
164
|
end
|
146
|
-
|
147
|
-
raise ArgumentError, "Servers must be either in the format 'host:port[:weight]' (e.g., 'localhost:11211' or 'localhost:11211:10') for a network server, or a valid path to a Unix domain socket (e.g., /var/run/memcached)."
|
148
|
-
end
|
165
|
+
)
|
149
166
|
end
|
150
167
|
# For inspect
|
151
168
|
@servers = send(:servers)
|
@@ -158,6 +175,27 @@ Please note that when pipelining is enabled, setter and deleter methods do not r
|
|
158
175
|
end
|
159
176
|
end
|
160
177
|
|
178
|
+
# Set the prefix key.
|
179
|
+
def set_prefix_key(key)
|
180
|
+
check_return_code(
|
181
|
+
if key
|
182
|
+
key += options[:prefix_delimiter]
|
183
|
+
raise ArgumentError, "Max prefix key + prefix delimiter size is #{Lib::MEMCACHED_PREFIX_KEY_MAX_SIZE - 1}" unless
|
184
|
+
key.size < Lib::MEMCACHED_PREFIX_KEY_MAX_SIZE
|
185
|
+
Lib.memcached_callback_set(@struct, Lib::MEMCACHED_CALLBACK_PREFIX_KEY, key)
|
186
|
+
else
|
187
|
+
Lib.memcached_callback_set(@struct, Lib::MEMCACHED_CALLBACK_PREFIX_KEY, "")
|
188
|
+
end
|
189
|
+
)
|
190
|
+
end
|
191
|
+
alias :set_namespace :set_prefix_key
|
192
|
+
|
193
|
+
# Return the current prefix key.
|
194
|
+
def prefix_key
|
195
|
+
@struct.prefix_key[0..-1 - options[:prefix_delimiter].size] if @struct.prefix_key.size > 0
|
196
|
+
end
|
197
|
+
alias :namespace :prefix_key
|
198
|
+
|
161
199
|
# Safely copy this instance. Returns a Memcached instance.
|
162
200
|
#
|
163
201
|
# <tt>clone</tt> is useful for threading, since each thread must have its own unshared Memcached
|
@@ -169,16 +207,21 @@ Please note that when pipelining is enabled, setter and deleter methods do not r
|
|
169
207
|
# struct = Lib.memcached_clone(nil, @struct)
|
170
208
|
# memcached.instance_variable_set('@struct', struct)
|
171
209
|
# memcached
|
172
|
-
self.class.new(servers, options)
|
210
|
+
self.class.new(servers, options.merge(:prefix_key => prefix_key))
|
173
211
|
end
|
174
212
|
|
175
213
|
# Reset the state of the libmemcached struct. This is useful for changing the server list at runtime.
|
176
|
-
def reset(current_servers = nil)
|
214
|
+
def reset(current_servers = nil, with_prefix_key = true)
|
215
|
+
# Store state and teardown
|
177
216
|
current_servers ||= servers
|
178
|
-
|
179
|
-
|
217
|
+
prev_prefix_key = prefix_key
|
218
|
+
|
219
|
+
# Create
|
220
|
+
# FIXME Duplicates logic with initialize()
|
221
|
+
@struct = Lib.memcached_create(nil)
|
222
|
+
set_prefix_key(prev_prefix_key) if with_prefix_key
|
180
223
|
set_behaviors
|
181
|
-
|
224
|
+
set_credentials
|
182
225
|
set_servers(current_servers)
|
183
226
|
end
|
184
227
|
|
@@ -192,6 +235,24 @@ Please note that when pipelining is enabled, setter and deleter methods do not r
|
|
192
235
|
alias :dup :clone #:nodoc:
|
193
236
|
#:startdoc:
|
194
237
|
|
238
|
+
# change the prefix_key after we're in motion
|
239
|
+
def prefix_key=(key)
|
240
|
+
unless key.size < Lib::MEMCACHED_PREFIX_KEY_MAX_SIZE
|
241
|
+
raise ArgumentError, "Max prefix_key size is #{Lib::MEMCACHED_PREFIX_KEY_MAX_SIZE - 1}"
|
242
|
+
end
|
243
|
+
check_return_code(
|
244
|
+
Lib.memcached_callback_set(@struct, Lib::MEMCACHED_CALLBACK_PREFIX_KEY, "#{key}#{options[:prefix_delimiter]}")
|
245
|
+
)
|
246
|
+
end
|
247
|
+
alias namespace= prefix_key=
|
248
|
+
|
249
|
+
# report the prefix_key
|
250
|
+
def prefix_key
|
251
|
+
@struct.prefix_key[0..-1 - options[:prefix_delimiter].size]
|
252
|
+
end
|
253
|
+
alias namespace prefix_key
|
254
|
+
|
255
|
+
|
195
256
|
### Configuration helpers
|
196
257
|
|
197
258
|
private
|
@@ -226,7 +287,7 @@ Please note that when pipelining is enabled, setter and deleter methods do not r
|
|
226
287
|
key
|
227
288
|
)
|
228
289
|
rescue ClientError
|
229
|
-
# FIXME Memcached 1.2.8 occasionally rejects valid sets
|
290
|
+
# FIXME Memcached 1.2.8 occasionally rejects valid sets
|
230
291
|
tried = 1 and retry unless defined?(tried)
|
231
292
|
raise
|
232
293
|
end
|
@@ -309,7 +370,10 @@ Please note that when pipelining is enabled, setter and deleter methods do not r
|
|
309
370
|
value = yield value
|
310
371
|
value = Marshal.dump(value) if marshal
|
311
372
|
|
312
|
-
check_return_code(
|
373
|
+
check_return_code(
|
374
|
+
Lib.memcached_cas(@struct, key, value, ttl, flags, cas),
|
375
|
+
key
|
376
|
+
)
|
313
377
|
end
|
314
378
|
|
315
379
|
alias :compare_and_swap :cas
|
@@ -372,17 +436,18 @@ Please note that when pipelining is enabled, setter and deleter methods do not r
|
|
372
436
|
def server_by_key(key)
|
373
437
|
ret = Lib.memcached_server_by_key(@struct, key)
|
374
438
|
if ret.is_a?(Array)
|
375
|
-
|
376
|
-
|
377
|
-
|
439
|
+
check_return_code(ret.last)
|
440
|
+
inspect_server(ret.first)
|
441
|
+
else
|
442
|
+
check_return_code(ret)
|
378
443
|
end
|
379
444
|
end
|
380
445
|
|
381
446
|
# Return a Hash of statistics responses from the set of servers. Each value is an array with one entry for each server, in the same order the servers were defined.
|
382
|
-
def stats
|
447
|
+
def stats(subcommand = nil)
|
383
448
|
stats = Hash.new([])
|
384
449
|
|
385
|
-
stat_struct, ret = Lib.memcached_stat(@struct,
|
450
|
+
stat_struct, ret = Lib.memcached_stat(@struct, subcommand)
|
386
451
|
check_return_code(ret)
|
387
452
|
|
388
453
|
keys, ret = Lib.memcached_stat_get_keys(@struct, stat_struct)
|
@@ -469,14 +534,12 @@ Please note that when pipelining is enabled, setter and deleter methods do not r
|
|
469
534
|
set_behavior(:hash, options[:hash])
|
470
535
|
end
|
471
536
|
|
472
|
-
# Set the
|
473
|
-
def
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
end
|
479
|
-
Lib.memcached_callback_set(@struct, Lib::MEMCACHED_CALLBACK_PREFIX_KEY, options[:prefix_key])
|
537
|
+
# Set the SASL credentials from the current options. If credentials aren't provided, try to get them from the environment.
|
538
|
+
def set_credentials
|
539
|
+
if options[:credentials]
|
540
|
+
check_return_code(
|
541
|
+
Lib.memcached_set_sasl_auth_data(@struct, *options[:credentials])
|
542
|
+
)
|
480
543
|
end
|
481
544
|
end
|
482
545
|
|
@@ -488,7 +551,7 @@ Please note that when pipelining is enabled, setter and deleter methods do not r
|
|
488
551
|
def inspect_server(server)
|
489
552
|
strings = [server.hostname]
|
490
553
|
if !is_unix_socket?(server)
|
491
|
-
strings << ":#{server.port}"
|
554
|
+
strings << ":#{server.port}"
|
492
555
|
strings << ":#{server.weight}" if options[:ketama_weighted]
|
493
556
|
end
|
494
557
|
strings.join
|
data/lib/memcached/rails.rb
CHANGED
@@ -76,8 +76,8 @@ class Memcached
|
|
76
76
|
end
|
77
77
|
|
78
78
|
# Wraps Memcached#delete so that it doesn't raise.
|
79
|
-
def delete(key)
|
80
|
-
super
|
79
|
+
def delete(key, expiry=0)
|
80
|
+
super(key)
|
81
81
|
rescue NotFound
|
82
82
|
end
|
83
83
|
|
@@ -105,11 +105,6 @@ class Memcached
|
|
105
105
|
rescue NotStored
|
106
106
|
end
|
107
107
|
|
108
|
-
# Namespace accessor.
|
109
|
-
def namespace
|
110
|
-
options[:prefix_key]
|
111
|
-
end
|
112
|
-
|
113
108
|
alias :flush_all :flush
|
114
109
|
|
115
110
|
alias :"[]" :get
|
data/memcached.gemspec
CHANGED
@@ -2,22 +2,22 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{memcached}
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.19.pre"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Evan Weaver"]
|
9
9
|
s.cert_chain = ["/Users/eweaver/p/configuration/gem_certificates/evan_weaver-original-public_cert.pem"]
|
10
|
-
s.date = %q{2010-
|
10
|
+
s.date = %q{2010-03-07}
|
11
11
|
s.description = %q{An interface to the libmemcached C client.}
|
12
12
|
s.email = %q{}
|
13
13
|
s.extensions = ["ext/extconf.rb"]
|
14
14
|
s.extra_rdoc_files = ["BENCHMARKS", "CHANGELOG", "LICENSE", "README", "TODO", "lib/memcached.rb", "lib/memcached/behaviors.rb", "lib/memcached/exceptions.rb", "lib/memcached/memcached.rb", "lib/memcached/rails.rb"]
|
15
|
-
s.files = ["BENCHMARKS", "CHANGELOG", "LICENSE", "Manifest", "README", "Rakefile", "TODO", "ext/extconf.rb", "ext/libmemcached-0.32.tar.gz", "ext/libmemcached.patch", "ext/rlibmemcached.i", "ext/rlibmemcached_wrap.c", "lib/memcached.rb", "lib/memcached/behaviors.rb", "lib/memcached/exceptions.rb", "lib/memcached/integer.rb", "lib/memcached/memcached.rb", "lib/memcached/rails.rb", "test/profile/benchmark.rb", "test/profile/profile.rb", "test/profile/valgrind.rb", "test/setup.rb", "test/teardown.rb", "test/test_helper.rb", "test/unit/binding_test.rb", "test/unit/memcached_test.rb", "test/unit/rails_test.rb", "memcached.gemspec"]
|
15
|
+
s.files = ["BENCHMARKS", "CHANGELOG", "LICENSE", "Manifest", "README", "Rakefile", "TODO", "ext/extconf.rb", "ext/libmemcached-0.32.tar.gz", "ext/libmemcached.patch", "ext/rlibmemcached.i", "ext/rlibmemcached_wrap.c", "ext/sasl.patch", "lib/memcached.rb", "lib/memcached/auth.rb", "lib/memcached/behaviors.rb", "lib/memcached/exceptions.rb", "lib/memcached/integer.rb", "lib/memcached/memcached.rb", "lib/memcached/rails.rb", "test/profile/benchmark.rb", "test/profile/profile.rb", "test/profile/valgrind.rb", "test/setup.rb", "test/teardown.rb", "test/test_helper.rb", "test/unit/binding_test.rb", "test/unit/memcached_test.rb", "test/unit/rails_test.rb", "memcached.gemspec"]
|
16
16
|
s.homepage = %q{http://blog.evanweaver.com/files/doc/fauna/memcached/}
|
17
17
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Memcached", "--main", "README"]
|
18
18
|
s.require_paths = ["lib", "ext"]
|
19
19
|
s.rubyforge_project = %q{fauna}
|
20
|
-
s.rubygems_version = %q{1.3.
|
20
|
+
s.rubygems_version = %q{1.3.6}
|
21
21
|
s.signing_key = %q{/Users/eweaver/p/configuration/gem_certificates/evan_weaver-original-private_key.pem}
|
22
22
|
s.summary = %q{An interface to the libmemcached C client.}
|
23
23
|
s.test_files = ["test/test_helper.rb", "test/unit/binding_test.rb", "test/unit/memcached_test.rb", "test/unit/rails_test.rb"]
|
data/test/unit/binding_test.rb
CHANGED
data/test/unit/memcached_test.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
require "#{File.dirname(__FILE__)}/../test_helper"
|
2
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../test_helper")
|
3
3
|
require 'socket'
|
4
4
|
require 'mocha'
|
5
5
|
require 'benchmark'
|
@@ -48,7 +48,7 @@ class MemcachedTest < Test::Unit::TestCase
|
|
48
48
|
|
49
49
|
def test_initialize
|
50
50
|
cache = Memcached.new @servers, :prefix_key => 'test'
|
51
|
-
assert_equal 'test', cache.
|
51
|
+
assert_equal 'test', cache.prefix_key
|
52
52
|
assert_equal 3, cache.send(:server_structs).size
|
53
53
|
assert_equal 'localhost', cache.send(:server_structs).first.hostname
|
54
54
|
assert_equal 43042, cache.send(:server_structs).first.port
|
@@ -91,7 +91,7 @@ class MemcachedTest < Test::Unit::TestCase
|
|
91
91
|
def test_options_are_set
|
92
92
|
Memcached::DEFAULTS.merge(@noblock_options).each do |key, expected|
|
93
93
|
value = @noblock_cache.options[key]
|
94
|
-
unless key == :rcv_timeout or key == :poll_timeout
|
94
|
+
unless key == :rcv_timeout or key == :poll_timeout or key == :prefix_key
|
95
95
|
assert(expected == value, "#{key} should be #{expected} but was #{value}")
|
96
96
|
end
|
97
97
|
end
|
@@ -133,6 +133,25 @@ class MemcachedTest < Test::Unit::TestCase
|
|
133
133
|
assert_equal 3, cache.send(:server_structs).size
|
134
134
|
end
|
135
135
|
|
136
|
+
def test_set_prefix_key
|
137
|
+
cache = Memcached.new @servers, :prefix_key => "foo"
|
138
|
+
cache.prefix_key = "bar"
|
139
|
+
assert_equal "bar", cache.prefix_key
|
140
|
+
end
|
141
|
+
|
142
|
+
def test_set_prefix_key_to_empty_string
|
143
|
+
cache = Memcached.new @servers, :prefix_key => "foo"
|
144
|
+
cache.prefix_key = ""
|
145
|
+
assert_equal "", cache.prefix_key
|
146
|
+
end
|
147
|
+
|
148
|
+
def test_memcached_callback_set_with_empty_string_should_not_raise_exception
|
149
|
+
cache = Memcached.new @servers, :prefix_key => "foo"
|
150
|
+
assert_nothing_raised do
|
151
|
+
cache.prefix_key = ""
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
136
155
|
def test_initialize_negative_behavior
|
137
156
|
cache = Memcached.new @servers,
|
138
157
|
:buffer_requests => false
|
data/test/unit/rails_test.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
require "#{File.dirname(__FILE__)}/../test_helper"
|
2
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../test_helper")
|
3
3
|
|
4
4
|
class RailsTest < Test::Unit::TestCase
|
5
5
|
|
@@ -41,6 +41,13 @@ class RailsTest < Test::Unit::TestCase
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
+
def test_delete_with_two_arguments
|
45
|
+
assert_nothing_raised do
|
46
|
+
@cache.delete(key, 5)
|
47
|
+
assert_nil(@cache.get(key))
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
44
51
|
def test_bracket_accessors
|
45
52
|
@cache[key] = @value
|
46
53
|
result = @cache[key]
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: memcached
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: true
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 19
|
8
|
+
- pre
|
9
|
+
version: 0.19.pre
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Evan Weaver
|
@@ -30,7 +35,7 @@ cert_chain:
|
|
30
35
|
yZ0=
|
31
36
|
-----END CERTIFICATE-----
|
32
37
|
|
33
|
-
date: 2010-
|
38
|
+
date: 2010-03-07 00:00:00 -08:00
|
34
39
|
default_executable:
|
35
40
|
dependencies: []
|
36
41
|
|
@@ -64,7 +69,9 @@ files:
|
|
64
69
|
- ext/libmemcached.patch
|
65
70
|
- ext/rlibmemcached.i
|
66
71
|
- ext/rlibmemcached_wrap.c
|
72
|
+
- ext/sasl.patch
|
67
73
|
- lib/memcached.rb
|
74
|
+
- lib/memcached/auth.rb
|
68
75
|
- lib/memcached/behaviors.rb
|
69
76
|
- lib/memcached/exceptions.rb
|
70
77
|
- lib/memcached/integer.rb
|
@@ -99,18 +106,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
99
106
|
requirements:
|
100
107
|
- - ">="
|
101
108
|
- !ruby/object:Gem::Version
|
109
|
+
segments:
|
110
|
+
- 0
|
102
111
|
version: "0"
|
103
|
-
version:
|
104
112
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
113
|
requirements:
|
106
114
|
- - ">="
|
107
115
|
- !ruby/object:Gem::Version
|
116
|
+
segments:
|
117
|
+
- 1
|
118
|
+
- 2
|
108
119
|
version: "1.2"
|
109
|
-
version:
|
110
120
|
requirements: []
|
111
121
|
|
112
122
|
rubyforge_project: fauna
|
113
|
-
rubygems_version: 1.3.
|
123
|
+
rubygems_version: 1.3.6
|
114
124
|
signing_key:
|
115
125
|
specification_version: 3
|
116
126
|
summary: An interface to the libmemcached C client.
|