jjp-memcache-client 1.8.7

Sign up to get free protection for your applications and to get access to all the features.
data/FAQ.rdoc ADDED
@@ -0,0 +1,32 @@
1
+ = Memcache-client FAQ
2
+
3
+ == Does memcache-client work with Ruby 1.9?
4
+
5
+ Yes, Ruby 1.9 is supported. The test suite should pass completely on 1.8.6 and 1.9.1.
6
+
7
+
8
+ == I'm seeing "execution expired" or "time's up!" errors, what's that all about?
9
+
10
+ memcache-client 1.6.x+ now has socket operations timed out by default. This is to prevent
11
+ the Ruby process from hanging if memcached or starling get into a bad state, which has been
12
+ seen in production by both 37signals and FiveRuns. The default timeout is 0.5 seconds, which
13
+ should be more than enough time under normal circumstances. It's possible to hit a storm of
14
+ concurrent events which cause this timer to expire: a large Ruby VM can cause the GC to take
15
+ a while, while also storing a large (500k-1MB value), for example.
16
+
17
+ You can increase the timeout or disable them completely with the following configuration:
18
+
19
+ Rails:
20
+ config.cache_store = :mem_cache_store, 'server1', 'server2', { :timeout => nil } # no timeout
21
+
22
+ native:
23
+ MemCache.new ['server1', 'server2'], { :timeout => 1.0 } # 1 second timeout
24
+
25
+
26
+ == Isn't Evan Weaver's memcached gem faster?
27
+
28
+ The latest version of memcached-client is anywhere from 33% to 100% slower than memcached in various
29
+ benchmarks. Keep in mind this means that 10,000 get requests take 1.8 sec instead of 1.2 seconds.
30
+ In practice, memcache-client is unlikely to be a bottleneck in your system but there is always going
31
+ to be an overhead to pure Ruby. memcache-client does have the advantage of built-in integration into
32
+ Rails and should work on non-MRI platforms: JRuby, MacRuby, etc.
data/History.rdoc ADDED
@@ -0,0 +1,288 @@
1
+ = 1.8.7 (2011-10-13)
2
+
3
+ * Added to MemCacheError "Value too large..." information about the cache_key under which such too large value was about to be stored. This way chasing code which is responsible for that error is possible whenever that error gets logged, no matter the logger level. Useful on production servers.
4
+
5
+ = 1.8.6 (HEAD)
6
+
7
+ * Use String#bytesize so non-ascii characters write correctly to the socket.
8
+
9
+ = 1.8.5 (2010-07-05)
10
+
11
+ * Fix bad release
12
+
13
+ = 1.8.4 (2010-07-02)
14
+
15
+ * Fix unfibered usage of memcache-client in EM
16
+ * Remove nag message (tenderlove)
17
+
18
+ = 1.8.3 (2010-04-26)
19
+
20
+ * Don't allow blank keys. (Bill Horsman)
21
+
22
+ = 1.8.2 (2010-04-03)
23
+
24
+ * Fix concurrency issues with eventmachine support.
25
+
26
+ = 1.8.1 (2010-03-20)
27
+
28
+ * Only require SystemTimer if the Ruby VM looks like MRI.
29
+ * Remove VERSION.yml usage as we should avoid using files outside of lib at runtime. (josh)
30
+
31
+ = 1.8.0 (2010-03-05)
32
+
33
+ * Add support for EventMachine-based connections.
34
+ * Add support for raw values in get_multi
35
+ * Add memcached_top binary for gathering server statistics
36
+
37
+ = 1.7.8 (2010-02-03)
38
+
39
+ * Fix issue where autofix_keys logic did not account for namespace length. (menno)
40
+ * Fix issue when using memcache-client without rubygems. (anvar)
41
+ * Fix issue when using the cas method with raw=true (Takahiro Kikumoto)
42
+
43
+ = 1.7.7 (2009-11-24)
44
+
45
+ * Fix invalid delete request in memcached 1.4.x. The expiry parameter to MemCache#delete is
46
+ now ignored as memcached 1.4.x has dropped support for this feature.
47
+
48
+ = 1.7.6 (2009-11-03)
49
+
50
+ * Reworked socket timeout code due to several customer complaints about timeouts not
51
+ working 100% of the time since 1.7.3.
52
+ * Add option to configure the namespace separator string, for interop with Perl
53
+ which does not use a separator character:
54
+ MemCache.new(servers, :namespace_separator => '')
55
+ * Move to jeweler and gemcutter for RubyGem support.
56
+
57
+ = 1.7.5 (2009-09-09)
58
+
59
+ * Fix ruby warnings (josh)
60
+ * Make megabyte value size limit optional since Tokyo Tyrant can accept values larger than 1MB.
61
+ Use :check_size => false to disable the size check. (jsl)
62
+ * Ruby 1.9 support for recent I/O changes.
63
+ * Fix duplicate value marshalling on server error. (rajiv)
64
+ * Added option :autofix_keys (disabled by default) to replace long keys with md5 hashes (sd)
65
+
66
+ = 1.7.4 (2009-06-09)
67
+
68
+ * Fix issue with raising timeout errors.
69
+
70
+ = 1.7.3 (2009-06-06)
71
+
72
+ * Remove SystemTimer support, refactor I/O to use nonblocking operations. Speeds up
73
+ performance approx 100%. Timeouts basically have no overhead now! (tenderlove)
74
+ * Update load logic to support SystemTimer running in Ruby Enterprise Edition. Thanks
75
+ to splattael on github for the comment.
76
+
77
+ = 1.7.2 (2009-04-12)
78
+
79
+ * Rollback socket timeout optimization. It does not work on all operating systems
80
+ and was a support headache.
81
+
82
+ = 1.7.1 (2009-03-28)
83
+
84
+ * Performance optimizations:
85
+ * Rely on higher performance operating system socket timeouts for low-level socket
86
+ read/writes where possible, instead of the (slower) SystemTimer or (slowest,
87
+ unreliable) Timeout libraries.
88
+ * the native binary search is back! The recent performance tuning made the binary search
89
+ a bottleneck again so it had to return. It uses RubyInline to compile the native extension and
90
+ silently falls back to pure Ruby if anything fails. Make sure you run:
91
+ `gem install RubyInline` if you want ultimate performance.
92
+ * the changes make memcache-client 100% faster than 1.7.0 in my performance test on Ruby 1.8.6:
93
+ 15 sec -> 8 sec.
94
+ * Fix several logging issues.
95
+
96
+ = 1.7.0 (2009-03-08)
97
+
98
+ * Go through the memcached protocol document and implement any commands not already implemented:
99
+ - cas
100
+ - append
101
+ - prepend
102
+ - replace
103
+
104
+ Append and prepend only work with raw data since it makes no sense to concatenate two Marshalled
105
+ values together. The cas functionality should be considered a prototype. Since I don't have an
106
+ application which uses +cas+, I'm not sure what semantic sugar the API should provide. Should it
107
+ retry if the value was changed? Should it massage the returned string into true/false? Feedback
108
+ would be appreciated.
109
+
110
+ * Add fetch method which provides a method very similar to ActiveSupport::Cache::Store#fetch,
111
+ basically a wrapper around get and add. (djanowski)
112
+
113
+ * Implement the flush_all delay parameter, to allow a large memcached farm to be flushed gradually.
114
+
115
+ * Implement the noreply flag, which tells memcached not to reply in operations which don't
116
+ need a reply, i.e. set/add/delete/flush_all.
117
+
118
+ * The only known functionality not implemented anymore is the <flags> parameter to the storage
119
+ commands. This would require modification of the API method signatures. If someone can come
120
+ up with a clean way to implement it, I would be happy to consider including it.
121
+
122
+ = 1.6.5 (2009-02-27)
123
+
124
+ * Change memcache-client to multithreaded by default. The mutex does not add significant
125
+ overhead and it is far too easy, now that Sinatra, Rails and Merb are all thread-safe, to
126
+ use memcache-client in a thread-unsafe manner. Remove some unnecessary mutexing and add
127
+ a test to verify heavily multithreaded usage does not act unexpectedly.
128
+
129
+ * Add optional support for the SystemTimer gem when running on Ruby 1.8.x. This gem is
130
+ highly recommended - it ensures timeouts actually work and halves the overhead of using
131
+ timeouts. Using this gem, Ruby 1.8.x is actually faster in my performance tests
132
+ than Ruby 1.9.x. Just "gem install SystemTimer" and it should be picked up automatically.
133
+
134
+ = 1.6.4 (2009-02-19)
135
+
136
+ * Remove native code altogether. The speedup was only 10% on Ruby 1.8.6 and did not work
137
+ on Ruby 1.9.1.
138
+
139
+ * Removed memcache_util.rb from the distribution. If you are using it, please copy the code
140
+ into your own project. The file will live in the github repository for a few more months
141
+ for this purposes. http://github.com/mperham/memcache-client/raw/7a276089aa3c914e47e3960f9740ac7377204970/lib/memcache_util.rb
142
+
143
+ * Roll continuum.rb into memcache.rb. The project is again a single Ruby file, with no dependencies.
144
+
145
+ = 1.6.3 (2009-02-14)
146
+
147
+ * Remove gem native extension in preference to RubyInline. This allows the gem to install
148
+ and work on JRuby and Ruby 1.8.5 when the native code fails to compile.
149
+
150
+ = 1.6.2 (2009-02-04)
151
+
152
+ * Validate that values are less than one megabyte in size.
153
+
154
+ * Refactor error handling in get_multi to handle server failures and return what values
155
+ we could successfully retrieve.
156
+
157
+ * Add optional logging parameter for debugging and tracing.
158
+
159
+ * First official release since 1.5.0. Thanks to Eric Hodel for turning over the project to me!
160
+ New project home page: http://github.com/mperham/memcache-client
161
+
162
+ = 1.6.1 (2009-01-28)
163
+
164
+ * Add option to disable socket timeout support. Socket timeout has a significant performance
165
+ penalty (approx 3x slower than without in Ruby 1.8.6). You can turn off the timeouts if you
166
+ need absolute performance, but by default timeouts are enabled. The performance
167
+ penalty is much lower in Ruby 1.8.7, 1.9 and JRuby. (mperham)
168
+
169
+ * Add option to disable server failover. Failover can lead to "split-brain" caches that
170
+ return stale data. (mperham)
171
+
172
+ * Implement continuum binary search in native code for performance reasons. Pure ruby
173
+ is available for platforms like JRuby or Rubinius which can't use C extensions. (mperham)
174
+
175
+ * Fix #add with raw=true (iamaleksey)
176
+
177
+ = 1.6.0
178
+
179
+ * Implement a consistent hashing algorithm, as described in libketama.
180
+ This dramatically reduces the cost of adding or removing servers dynamically
181
+ as keys are much more likely to map to the same server.
182
+
183
+ Take a scenario where we add a fourth server. With a naive modulo algorithm, about
184
+ 25% of the keys will map to the same server. In other words, 75% of your memcached
185
+ content suddenly becomes invalid. With a consistent algorithm, 75% of the keys
186
+ will map to the same server as before - only 25% will be invalidated. (mperham)
187
+
188
+ * Implement socket timeouts, should fix rare cases of very bad things happening
189
+ in production at 37signals and FiveRuns. (jseirles)
190
+
191
+ = 1.5.0.5
192
+
193
+ * Remove native C CRC32_ITU_T extension in favor of Zlib's crc32 method.
194
+ memcache-client is now pure Ruby again and will work with JRuby and Rubinius.
195
+
196
+ = 1.5.0.4
197
+
198
+ * Get test suite working again (packagethief)
199
+ * Ruby 1.9 compatiblity fixes (packagethief, mperham)
200
+ * Consistently return server responses and check for errors (packagethief)
201
+ * Properly calculate CRC in Ruby 1.9 strings (mperham)
202
+ * Drop rspec in favor of test/unit, for 1.9 compat (mperham)
203
+
204
+ = 1.5.0.3 (FiveRuns fork)
205
+
206
+ * Integrated ITU-T CRC32 operation in native C extension for speed. Thanks to Justin Balthrop!
207
+
208
+ = 1.5.0.2 (FiveRuns fork)
209
+
210
+ * Add support for seamless failover between servers. If one server connection dies,
211
+ the client will retry the operation on another server before giving up.
212
+
213
+ * Merge Will Bryant's socket retry patch.
214
+ http://willbryant.net/software/2007/12/21/ruby-memcache-client-reconnect-and-retry
215
+
216
+ = 1.5.0.1 (FiveRuns fork)
217
+
218
+ * Fix set not handling client disconnects.
219
+ http://dev.twitter.com/2008/02/solving-case-of-missing-updates.html
220
+
221
+ = 1.5.0
222
+
223
+ * Add MemCache#flush_all command. Patch #13019 and bug #10503. Patches
224
+ submitted by Sebastian Delmont and Rick Olson.
225
+ * Type-cast data returned by MemCache#stats. Patch #10505 submitted by
226
+ Sebastian Delmont.
227
+
228
+ = 1.4.0
229
+
230
+ * Fix bug #10371, #set does not check response for server errors.
231
+ Submitted by Ben VandenBos.
232
+ * Fix bug #12450, set TCP_NODELAY socket option. Patch by Chris
233
+ McGrath.
234
+ * Fix bug #10704, missing #add method. Patch by Jamie Macey.
235
+ * Fix bug #10371, handle socket EOF in cache_get. Submitted by Ben
236
+ VandenBos.
237
+
238
+ = 1.3.0
239
+
240
+ * Apply patch #6507, add stats command. Submitted by Tyler Kovacs.
241
+ * Apply patch #6509, parallel implementation of #get_multi. Submitted
242
+ by Tyler Kovacs.
243
+ * Validate keys. Disallow spaces in keys or keys that are too long.
244
+ * Perform more validation of server responses. MemCache now reports
245
+ errors if the socket was not in an expected state. (Please file
246
+ bugs if you find some.)
247
+ * Add #incr and #decr.
248
+ * Add raw argument to #set and #get to retrieve #incr and #decr
249
+ values.
250
+ * Also put on MemCacheError when using Cache::get with block.
251
+ * memcache.rb no longer sets $TESTING to a true value if it was
252
+ previously defined. Bug #8213 by Matijs van Zuijlen.
253
+
254
+ = 1.2.1
255
+
256
+ * Fix bug #7048, MemCache#servers= referenced changed local variable.
257
+ Submitted by Justin Dossey.
258
+ * Fix bug #7049, MemCache#initialize resets @buckets. Submitted by
259
+ Justin Dossey.
260
+ * Fix bug #6232, Make Cache::Get work with a block only when nil is
261
+ returned. Submitted by Jon Evans.
262
+ * Moved to the seattlerb project.
263
+
264
+ = 1.2.0
265
+
266
+ NOTE: This version will store keys in different places than previous
267
+ versions! Be prepared for some thrashing while memcached sorts itself
268
+ out!
269
+
270
+ * Fixed multithreaded operations, bug 5994 and 5989.
271
+ Thanks to Blaine Cook, Erik Hetzner, Elliot Smith, Dave Myron (and
272
+ possibly others I have forgotten).
273
+ * Made memcached interoperable with other memcached libraries, bug
274
+ 4509. Thanks to anonymous.
275
+ * Added get_multi to match Perl/etc APIs
276
+
277
+ = 1.1.0
278
+
279
+ * Added some tests
280
+ * Sped up non-multithreaded and multithreaded operation
281
+ * More Ruby-memcache compatibility
282
+ * More RDoc
283
+ * Switched to Hoe
284
+
285
+ = 1.0.0
286
+
287
+ Birthday!
288
+
data/LICENSE.txt ADDED
@@ -0,0 +1,28 @@
1
+ Copyright 2005-2009 Bob Cottrell, Eric Hodel, Mike Perham.
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions
6
+ are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright
9
+ notice, this list of conditions and the following disclaimer.
10
+ 2. Redistributions in binary form must reproduce the above copyright
11
+ notice, this list of conditions and the following disclaimer in the
12
+ documentation and/or other materials provided with the distribution.
13
+ 3. Neither the names of the authors nor the names of their contributors
14
+ may be used to endorse or promote products derived from this software
15
+ without specific prior written permission.
16
+
17
+ THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
18
+ OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE
21
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
22
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
23
+ OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24
+ BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
27
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
+
data/README.rdoc ADDED
@@ -0,0 +1,70 @@
1
+ = memcache-client
2
+
3
+ A ruby library for accessing memcached.
4
+
5
+ == memcache-client is deprecated as of August 2010. It will be supported through 2010 but new code should use Dalli[http://github.com/mperham/dalli] instead.
6
+
7
+
8
+ Source:
9
+
10
+ http://github.com/mperham/memcache-client
11
+
12
+ == Installing memcache-client
13
+
14
+ Just install the gem:
15
+
16
+ $ sudo gem install memcache-client
17
+
18
+ == Using memcache-client
19
+
20
+ With one server:
21
+
22
+ CACHE = MemCache.new 'localhost:11211'
23
+
24
+ Or with multiple servers:
25
+
26
+ CACHE = MemCache.new %w[one.example.com:11211 two.example.com:11211]
27
+
28
+
29
+ == Tuning memcache-client
30
+
31
+ The MemCache.new method takes a number of options which can be useful at times. Please
32
+ read the source comments there for an overview. If you are using Ruby 1.8.x and using
33
+ multiple memcached servers, you should install the RubyInline gem for ultimate performance.
34
+
35
+
36
+ == Using memcache-client with Rails
37
+
38
+ Rails 2.1+ includes memcache-client 1.5.0 out of the box. See ActiveSupport::Cache::MemCacheStore
39
+ and the Rails.cache method for more details. Rails 2.3+ will use the latest memcache-client
40
+ gem installed.
41
+
42
+ == Using memcache-client with EventMachine
43
+
44
+ memcache-client 1.8.0 added support for native EventMachine connections using
45
+ Ruby 1.9. If you are using an EventMachine-based application (e.g. thin), you can
46
+ activate the EventMachine support like so:
47
+
48
+ require 'memcache'
49
+ require 'memcache/event_machine'
50
+
51
+ EM.run do
52
+ Fiber.new do
53
+ m = MemCache.new('localhost:11211')
54
+ m.set 'abc', 'xyz'
55
+ m.get 'abc'
56
+ end.resume
57
+ end
58
+
59
+ == Questions?
60
+
61
+ memcache-client is maintained by Mike Perham and was originally written by Bob Cottrell,
62
+ Eric Hodel and the seattle.rb crew.
63
+
64
+ Email:: mailto:mperham@gmail.com
65
+ Twitter:: mperham[http://twitter.com/mperham]
66
+ WWW:: http://mikeperham.com
67
+
68
+ If my work on memcache-client is something you support, please take a moment to
69
+ recommend me at WWR[http://workingwithrails.com/person/10797-mike-perham]. I'm not
70
+ asking for money, just a electronic "thumbs up".
data/Rakefile ADDED
@@ -0,0 +1,42 @@
1
+ # vim: syntax=Ruby
2
+ require 'rubygems'
3
+ require 'rake/rdoctask'
4
+ require 'rake/testtask'
5
+
6
+ require File.dirname(__FILE__) + "/lib/memcache/version.rb"
7
+ begin
8
+ require 'jeweler'
9
+ Jeweler::Tasks.new do |s|
10
+ s.name = "memcache-client"
11
+ s.version = MemCache::VERSION
12
+ s.summary = s.description = "A Ruby library for accessing memcached."
13
+ s.email = "mperham@gmail.com"
14
+ s.homepage = "http://github.com/mperham/memcache-client"
15
+ s.authors = ['Eric Hodel', 'Robert Cottrell', 'Mike Perham']
16
+ s.has_rdoc = true
17
+ s.files = FileList["[A-Z]*", "{lib,test}/**/*", 'performance.txt']
18
+ s.test_files = FileList["test/test_*.rb"]
19
+ s.executables = ['memcached_top']
20
+ end
21
+ Jeweler::GemcutterTasks.new
22
+ rescue LoadError
23
+ puts "Jeweler not available. Install it for jeweler-related tasks with: sudo gem install jeweler"
24
+ end
25
+
26
+
27
+ Rake::RDocTask.new do |rd|
28
+ rd.main = "README.rdoc"
29
+ rd.rdoc_files.include("README.rdoc", "FAQ.rdoc", "History.rdoc", "lib/memcache.rb")
30
+ rd.rdoc_dir = 'doc'
31
+ end
32
+
33
+ Rake::TestTask.new do |t|
34
+ t.warning = true
35
+ t.libs = ['lib', 'test']
36
+ end
37
+
38
+ task :default => :test
39
+
40
+ task :rcov do
41
+ `rcov -Ilib test/*.rb`
42
+ end