ninjudd-ninjudd-memcache-client 1.5.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +85 -0
- data/README.txt +54 -0
- data/Rakefile +24 -0
- data/ext/crc32/crc32.c +28 -0
- data/ext/crc32/extconf.rb +5 -0
- data/lib/memcache.rb +791 -0
- data/lib/memcache_extended.rb +112 -0
- data/lib/memcache_mock.rb +126 -0
- data/lib/memcache_util.rb +90 -0
- data/test/test_mem_cache.rb +744 -0
- data/test/test_memcache_extended.rb +27 -0
- data/test/test_memcache_mock.rb +94 -0
- metadata +66 -0
data/History.txt
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
= 1.5.0.3 (FiveRuns fork)
|
2
|
+
|
3
|
+
* Integrated ITU-T CRC32 operation in native C extension for speed. Thanks to Justin Balthrop!
|
4
|
+
|
5
|
+
= 1.5.0.2 (FiveRuns fork)
|
6
|
+
|
7
|
+
* Add support for seamless failover between servers. If one server connection dies,
|
8
|
+
the client will retry the operation on another server before giving up.
|
9
|
+
|
10
|
+
* Merge Will Bryant's socket retry patch.
|
11
|
+
http://willbryant.net/software/2007/12/21/ruby-memcache-client-reconnect-and-retry
|
12
|
+
|
13
|
+
= 1.5.0.1 (FiveRuns fork)
|
14
|
+
|
15
|
+
* Fix set not handling client disconnects.
|
16
|
+
http://dev.twitter.com/2008/02/solving-case-of-missing-updates.html
|
17
|
+
|
18
|
+
= 1.5.0
|
19
|
+
|
20
|
+
* Add MemCache#flush_all command. Patch #13019 and bug #10503. Patches
|
21
|
+
submitted by Sebastian Delmont and Rick Olson.
|
22
|
+
* Type-cast data returned by MemCache#stats. Patch #10505 submitted by
|
23
|
+
Sebastian Delmont.
|
24
|
+
|
25
|
+
= 1.4.0
|
26
|
+
|
27
|
+
* Fix bug #10371, #set does not check response for server errors.
|
28
|
+
Submitted by Ben VandenBos.
|
29
|
+
* Fix bug #12450, set TCP_NODELAY socket option. Patch by Chris
|
30
|
+
McGrath.
|
31
|
+
* Fix bug #10704, missing #add method. Patch by Jamie Macey.
|
32
|
+
* Fix bug #10371, handle socket EOF in cache_get. Submitted by Ben
|
33
|
+
VandenBos.
|
34
|
+
|
35
|
+
= 1.3.0
|
36
|
+
|
37
|
+
* Apply patch #6507, add stats command. Submitted by Tyler Kovacs.
|
38
|
+
* Apply patch #6509, parallel implementation of #get_multi. Submitted
|
39
|
+
by Tyler Kovacs.
|
40
|
+
* Validate keys. Disallow spaces in keys or keys that are too long.
|
41
|
+
* Perform more validation of server responses. MemCache now reports
|
42
|
+
errors if the socket was not in an expected state. (Please file
|
43
|
+
bugs if you find some.)
|
44
|
+
* Add #incr and #decr.
|
45
|
+
* Add raw argument to #set and #get to retrieve #incr and #decr
|
46
|
+
values.
|
47
|
+
* Also put on MemCacheError when using Cache::get with block.
|
48
|
+
* memcache.rb no longer sets $TESTING to a true value if it was
|
49
|
+
previously defined. Bug #8213 by Matijs van Zuijlen.
|
50
|
+
|
51
|
+
= 1.2.1
|
52
|
+
|
53
|
+
* Fix bug #7048, MemCache#servers= referenced changed local variable.
|
54
|
+
Submitted by Justin Dossey.
|
55
|
+
* Fix bug #7049, MemCache#initialize resets @buckets. Submitted by
|
56
|
+
Justin Dossey.
|
57
|
+
* Fix bug #6232, Make Cache::Get work with a block only when nil is
|
58
|
+
returned. Submitted by Jon Evans.
|
59
|
+
* Moved to the seattlerb project.
|
60
|
+
|
61
|
+
= 1.2.0
|
62
|
+
|
63
|
+
NOTE: This version will store keys in different places than previous
|
64
|
+
versions! Be prepared for some thrashing while memcached sorts itself
|
65
|
+
out!
|
66
|
+
|
67
|
+
* Fixed multithreaded operations, bug 5994 and 5989.
|
68
|
+
Thanks to Blaine Cook, Erik Hetzner, Elliot Smith, Dave Myron (and
|
69
|
+
possibly others I have forgotten).
|
70
|
+
* Made memcached interoperable with other memcached libraries, bug
|
71
|
+
4509. Thanks to anonymous.
|
72
|
+
* Added get_multi to match Perl/etc APIs
|
73
|
+
|
74
|
+
= 1.1.0
|
75
|
+
|
76
|
+
* Added some tests
|
77
|
+
* Sped up non-multithreaded and multithreaded operation
|
78
|
+
* More Ruby-memcache compatibility
|
79
|
+
* More RDoc
|
80
|
+
* Switched to Hoe
|
81
|
+
|
82
|
+
= 1.0.0
|
83
|
+
|
84
|
+
Birthday!
|
85
|
+
|
data/README.txt
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
= memcache-client
|
2
|
+
|
3
|
+
This is the FiveRuns fork of seattle.rb's memcache-client 1.5.0. We've fixed several bugs
|
4
|
+
which are in that version.
|
5
|
+
|
6
|
+
Rubyforge Project:
|
7
|
+
|
8
|
+
http://rubyforge.org/projects/seattlerb
|
9
|
+
|
10
|
+
Documentation:
|
11
|
+
|
12
|
+
http://seattlerb.org/memcache-client
|
13
|
+
|
14
|
+
== Installing memcache-client
|
15
|
+
|
16
|
+
Just install the gem:
|
17
|
+
|
18
|
+
$ sudo gem install fiveruns-memcache-client --source http://gems.github.com
|
19
|
+
|
20
|
+
== Using memcache-client
|
21
|
+
|
22
|
+
With one server:
|
23
|
+
|
24
|
+
CACHE = MemCache.new 'localhost:11211', :namespace => 'my_namespace'
|
25
|
+
|
26
|
+
Or with multiple servers:
|
27
|
+
|
28
|
+
CACHE = MemCache.new %w[one.example.com:11211 two.example.com:11211],
|
29
|
+
:namespace => 'my_namespace'
|
30
|
+
|
31
|
+
See MemCache.new for details.
|
32
|
+
|
33
|
+
=== Using memcache-client with Rails
|
34
|
+
|
35
|
+
Rails will automatically load the memcache-client gem, but you may
|
36
|
+
need to uninstall Ruby-memcache, I don't know which one will get
|
37
|
+
picked by default.
|
38
|
+
|
39
|
+
Add your environment-specific caches to config/environment/*. If you run both
|
40
|
+
development and production on the same memcached server sets, be sure
|
41
|
+
to use different namespaces. Be careful when running tests using
|
42
|
+
memcache, you may get strange results. It will be less of a headache
|
43
|
+
to simply use a readonly memcache when testing.
|
44
|
+
|
45
|
+
memcache-client also comes with a wrapper called Cache in memcache_util.rb for
|
46
|
+
use with Rails. To use it be sure to assign your memcache connection to
|
47
|
+
CACHE. Cache returns nil on all memcache errors so you don't have to rescue
|
48
|
+
the errors yourself. It has #get, #put and #delete module functions.
|
49
|
+
|
50
|
+
=== Improving Performance ===
|
51
|
+
|
52
|
+
Performing the CRC-32 ITU-T step to determine which server to use for a given key
|
53
|
+
is VERY slow in Ruby. RubyGems should compile a native library for performing this
|
54
|
+
operation when the gem is installed.
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# vim: syntax=Ruby
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
require 'spec/rake/spectask'
|
5
|
+
|
6
|
+
task :gem do
|
7
|
+
sh "gem build memcache-client.gemspec"
|
8
|
+
end
|
9
|
+
|
10
|
+
task :install => [:gem] do
|
11
|
+
sh "sudo gem install memcache-client-*.gem"
|
12
|
+
end
|
13
|
+
|
14
|
+
Spec::Rake::SpecTask.new do |t|
|
15
|
+
t.ruby_opts = ['-rtest/unit']
|
16
|
+
t.spec_files = FileList['test/test_*.rb']
|
17
|
+
t.fail_on_error = true
|
18
|
+
end
|
19
|
+
|
20
|
+
Rake::RDocTask.new do |rd|
|
21
|
+
rd.main = "README.rdoc"
|
22
|
+
rd.rdoc_files.include("README.rdoc", "lib/**/*.rb")
|
23
|
+
rd.rdoc_dir = 'doc'
|
24
|
+
end
|
data/ext/crc32/crc32.c
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#include "ruby.h"
|
2
|
+
#include "stdio.h"
|
3
|
+
|
4
|
+
static VALUE t_itu_t(VALUE self, VALUE string) {
|
5
|
+
VALUE str = StringValue(string);
|
6
|
+
int n = RSTRING(str)->len;
|
7
|
+
char* p = RSTRING(str)->ptr;
|
8
|
+
unsigned long r = 0xFFFFFFFF;
|
9
|
+
int i, j;
|
10
|
+
|
11
|
+
for (i = 0; i < n; i++) {
|
12
|
+
r = r ^ p[i];
|
13
|
+
for (j = 0; j < 8; j++) {
|
14
|
+
if ( (r & 1) != 0 ) {
|
15
|
+
r = (r >> 1) ^ 0xEDB88320;
|
16
|
+
} else {
|
17
|
+
r = r >> 1;
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}
|
21
|
+
return INT2FIX(r ^ 0xFFFFFFFF);
|
22
|
+
}
|
23
|
+
|
24
|
+
VALUE cCRC32;
|
25
|
+
void Init_crc32() {
|
26
|
+
cCRC32 = rb_define_module("CRC32");
|
27
|
+
rb_define_module_function(cCRC32, "itu_t", t_itu_t, 1);
|
28
|
+
}
|