fiveruns-fiveruns-memcache-client 1.5.0.2 → 1.5.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/README.txt +9 -9
- data/ext/crc32/crc32.c +28 -0
- data/ext/crc32/extconf.rb +5 -0
- data/lib/memcache.rb +23 -15
- metadata +6 -5
data/History.txt
CHANGED
data/README.txt
CHANGED
@@ -1,26 +1,21 @@
|
|
1
1
|
= memcache-client
|
2
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
|
+
|
3
6
|
Rubyforge Project:
|
4
7
|
|
5
8
|
http://rubyforge.org/projects/seattlerb
|
6
9
|
|
7
|
-
File bugs:
|
8
|
-
|
9
|
-
http://rubyforge.org/tracker/?func=add&group_id=1513&atid=5921
|
10
|
-
|
11
10
|
Documentation:
|
12
11
|
|
13
12
|
http://seattlerb.org/memcache-client
|
14
13
|
|
15
|
-
== About
|
16
|
-
|
17
|
-
memcache-client is a client for Danga Interactive's memcached.
|
18
|
-
|
19
14
|
== Installing memcache-client
|
20
15
|
|
21
16
|
Just install the gem:
|
22
17
|
|
23
|
-
$ sudo gem install memcache-client
|
18
|
+
$ sudo gem install fiveruns-memcache-client --source http://gems.github.com
|
24
19
|
|
25
20
|
== Using memcache-client
|
26
21
|
|
@@ -52,3 +47,8 @@ use with Rails. To use it be sure to assign your memcache connection to
|
|
52
47
|
CACHE. Cache returns nil on all memcache errors so you don't have to rescue
|
53
48
|
the errors yourself. It has #get, #put and #delete module functions.
|
54
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/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
|
+
}
|
data/lib/memcache.rb
CHANGED
@@ -9,25 +9,33 @@ class String
|
|
9
9
|
|
10
10
|
##
|
11
11
|
# Uses the ITU-T polynomial in the CRC32 algorithm.
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
12
|
+
begin
|
13
|
+
require 'crc32'
|
14
|
+
def crc32_ITU_T
|
15
|
+
CRC32.itu_t(self)
|
16
|
+
end
|
17
|
+
rescue LoadError => e
|
18
|
+
puts "Loading with slow CRC32 ITU-T implementation: #{e.message}"
|
19
|
+
|
20
|
+
def crc32_ITU_T
|
21
|
+
n = length
|
22
|
+
r = 0xFFFFFFFF
|
23
|
+
|
24
|
+
n.times do |i|
|
25
|
+
r ^= self[i]
|
26
|
+
8.times do
|
27
|
+
if (r & 1) != 0 then
|
28
|
+
r = (r>>1) ^ 0xEDB88320
|
29
|
+
else
|
30
|
+
r >>= 1
|
31
|
+
end
|
24
32
|
end
|
25
33
|
end
|
26
|
-
end
|
27
34
|
|
28
|
-
|
35
|
+
r ^ 0xFFFFFFFF
|
36
|
+
end
|
29
37
|
end
|
30
|
-
|
38
|
+
|
31
39
|
end
|
32
40
|
|
33
41
|
##
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fiveruns-fiveruns-memcache-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.0.
|
4
|
+
version: 1.5.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Hodel
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2008-
|
14
|
+
date: 2008-06-25 00:00:00 -07:00
|
15
15
|
default_executable:
|
16
16
|
dependencies: []
|
17
17
|
|
@@ -19,8 +19,8 @@ description: A Ruby-based memcached client library
|
|
19
19
|
email: mike@fiveruns.com
|
20
20
|
executables: []
|
21
21
|
|
22
|
-
extensions:
|
23
|
-
|
22
|
+
extensions:
|
23
|
+
- ext/crc32/extconf.rb
|
24
24
|
extra_rdoc_files: []
|
25
25
|
|
26
26
|
files:
|
@@ -30,6 +30,7 @@ files:
|
|
30
30
|
- Rakefile
|
31
31
|
- lib/memcache.rb
|
32
32
|
- lib/memcache_util.rb
|
33
|
+
- ext/crc32/crc32.c
|
33
34
|
has_rdoc: false
|
34
35
|
homepage: http://github.com/fiveruns/memcache-client
|
35
36
|
post_install_message:
|
@@ -52,7 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
52
53
|
requirements: []
|
53
54
|
|
54
55
|
rubyforge_project:
|
55
|
-
rubygems_version: 1.0
|
56
|
+
rubygems_version: 1.2.0
|
56
57
|
signing_key:
|
57
58
|
specification_version: 2
|
58
59
|
summary: A Ruby-based memcached client library
|