arunthampi-memcached 0.17.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/.gitmodules +3 -0
- data/BENCHMARKS +120 -0
- data/CHANGELOG +58 -0
- data/LICENSE +184 -0
- data/Manifest +27 -0
- data/README +118 -0
- data/Rakefile +45 -0
- data/TODO +4 -0
- data/VERSION +1 -0
- data/ext/extconf.rb +106 -0
- data/ext/libmemcached-0.32.tar.gz +0 -0
- data/ext/libmemcached.patch +270 -0
- data/ext/rlibmemcached.i +212 -0
- data/ext/rlibmemcached_wrap.c +13090 -0
- data/lib/memcached.rb +31 -0
- data/lib/memcached/behaviors.rb +78 -0
- data/lib/memcached/exceptions.rb +84 -0
- data/lib/memcached/integer.rb +6 -0
- data/lib/memcached/memcached.rb +554 -0
- data/lib/memcached/rails.rb +97 -0
- data/test/profile/benchmark.rb +210 -0
- data/test/profile/profile.rb +14 -0
- data/test/profile/valgrind.rb +147 -0
- data/test/setup.rb +29 -0
- data/test/teardown.rb +0 -0
- data/test/test_helper.rb +18 -0
- data/test/unit/binding_test.rb +8 -0
- data/test/unit/memcached_test.rb +1132 -0
- data/test/unit/rails_test.rb +102 -0
- metadata +94 -0
data/.gitignore
ADDED
data/.gitmodules
ADDED
data/BENCHMARKS
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
|
2
|
+
Here are some benchmarks for various architectures and operating systems.
|
3
|
+
|
4
|
+
You can easily run your own benchmarks, as long as you have memcached itself on your system:
|
5
|
+
$ ruby -e 'system("ruby #{File.dirname(`gem which memcached`.split("\n").
|
6
|
+
last)}/../test/profile/benchmark.rb")'
|
7
|
+
|
8
|
+
== x86-64 OS X
|
9
|
+
|
10
|
+
These benchmarks were run on an OS X 10.5 Core 2 Duo machine:
|
11
|
+
|
12
|
+
Ruby 1.8.7p174
|
13
|
+
Loaded memcached 0.17
|
14
|
+
Loaded binary42-remix-stash 0.9.5
|
15
|
+
Loaded memcache-client 1.7.5
|
16
|
+
Loops is 40000
|
17
|
+
Stack depth is 0
|
18
|
+
Small value size is: 13 bytes
|
19
|
+
Large value size is: 4158 bytes
|
20
|
+
|
21
|
+
user system total real
|
22
|
+
set:libm 1.360000 2.120000 3.480000 ( 8.952505)
|
23
|
+
set:libm:binary 1.180000 2.100000 3.280000 ( 7.692065)
|
24
|
+
set:libm:noblock 0.590000 0.240000 0.830000 ( 1.863921)
|
25
|
+
set:libm:noblock_binary 0.470000 0.220000 0.690000 ( 1.678243)
|
26
|
+
set:libm:udp 1.140000 1.150000 2.290000 ( 4.835305)
|
27
|
+
set:ruby 15.440000 6.330000 21.770000 ( 22.136843)
|
28
|
+
set:stash 5.780000 2.040000 7.820000 ( 13.748268)
|
29
|
+
get:libm 1.600000 2.000000 3.600000 ( 8.112166)
|
30
|
+
get:libm:binary 1.360000 2.150000 3.510000 ( 7.829266)
|
31
|
+
get:libm:noblock 1.820000 2.630000 4.450000 ( 8.971191)
|
32
|
+
get:libm:noblock_binary 1.560000 2.650000 4.210000 ( 8.114088)
|
33
|
+
get:libm:udp 1.350000 1.140000 2.490000 ( 4.878485)
|
34
|
+
get:ruby 18.640000 6.370000 25.010000 ( 25.925459)
|
35
|
+
get:stash 5.120000 1.990000 7.110000 ( 11.850485)
|
36
|
+
get-multi:libm 1.770000 1.320000 3.090000 ( 4.790793)
|
37
|
+
get-multi:libm:binary 1.730000 1.740000 3.470000 ( 5.655120)
|
38
|
+
get-multi:libm:noblock 1.820000 1.330000 3.150000 ( 4.841084)
|
39
|
+
get-multi:libm:noblock_binary 1.740000 1.760000 3.500000 ( 5.616970)
|
40
|
+
get-multi:libm:udp 1.690000 0.960000 2.650000 ( 3.551923)
|
41
|
+
get-multi:ruby 21.380000 4.400000 25.780000 ( 26.017883)
|
42
|
+
append:libm 1.500000 2.180000 3.680000 ( 14.658051)
|
43
|
+
append:libm:binary 1.300000 2.110000 3.410000 ( 13.626305)
|
44
|
+
append:libm:noblock 1.850000 2.870000 4.720000 ( 45.167145)
|
45
|
+
append:libm:noblock_binary 1.640000 2.870000 4.510000 ( 44.614596)
|
46
|
+
append:libm:udp 1.260000 1.170000 2.430000 ( 11.556293)
|
47
|
+
append:ruby 16.770000 7.310000 24.080000 ( 29.525815)
|
48
|
+
delete:libm 1.890000 2.080000 3.970000 ( 8.368548)
|
49
|
+
delete:libm:binary 1.730000 2.090000 3.820000 ( 7.799952)
|
50
|
+
delete:libm:noblock 0.850000 0.890000 1.740000 ( 2.530108)
|
51
|
+
delete:libm:noblock_binary 0.710000 0.780000 1.490000 ( 2.390600)
|
52
|
+
delete:libm:udp 1.700000 1.310000 3.010000 ( 6.508360)
|
53
|
+
delete:ruby 15.670000 6.330000 22.000000 ( 22.226087)
|
54
|
+
delete:stash 4.970000 2.010000 6.980000 ( 11.726916)
|
55
|
+
get-missing:libm 2.070000 2.060000 4.130000 ( 8.937420)
|
56
|
+
get-missing:libm:binary 2.010000 2.090000 4.100000 ( 8.506150)
|
57
|
+
get-missing:libm:noblock 2.270000 2.770000 5.040000 ( 9.485592)
|
58
|
+
get-missing:libm:noblock_binary 2.220000 2.760000 4.980000 ( 9.226826)
|
59
|
+
get-missing:libm:udp 1.830000 1.300000 3.130000 ( 7.135699)
|
60
|
+
get-missing:ruby 16.130000 6.380000 22.510000 ( 22.888698)
|
61
|
+
get-missing:stash 5.030000 2.030000 7.060000 ( 11.556793)
|
62
|
+
append-missing:libm 2.210000 2.070000 4.280000 ( 10.386632)
|
63
|
+
append-missing:libm:binary 2.000000 2.060000 4.060000 ( 9.135312)
|
64
|
+
append-missing:libm:noblock 2.400000 2.740000 5.140000 ( 10.821778)
|
65
|
+
append-missing:libm:noblock_binary 2.200000 2.770000 4.970000 ( 9.699192)
|
66
|
+
append-missing:libm:udp 1.970000 1.320000 3.290000 ( 7.668878)
|
67
|
+
append-missing:ruby 15.970000 6.470000 22.440000 ( 22.912466)
|
68
|
+
set-large:libm 1.460000 2.210000 3.670000 ( 9.517034)
|
69
|
+
set-large:libm:binary 1.260000 2.270000 3.530000 ( 9.098769)
|
70
|
+
set-large:libm:noblock 0.980000 0.890000 1.870000 ( 3.304075)
|
71
|
+
set-large:libm:noblock_binary 0.840000 0.890000 1.730000 ( 3.444305)
|
72
|
+
set-large:libm:udp 1.250000 1.330000 2.580000 ( 6.924254)
|
73
|
+
set-large:ruby 16.960000 6.490000 23.450000 ( 23.964380)
|
74
|
+
get-large:libm 2.280000 2.450000 4.730000 ( 9.908532)
|
75
|
+
get-large:libm:binary 2.080000 2.530000 4.610000 ( 8.966637)
|
76
|
+
get-large:libm:noblock 2.410000 2.850000 5.260000 ( 11.066391)
|
77
|
+
get-large:libm:noblock_binary 2.200000 2.910000 5.110000 ( 10.328922)
|
78
|
+
get-large:libm:udp 2.010000 1.430000 3.440000 ( 6.679192)
|
79
|
+
get-large:ruby 21.790000 7.370000 29.160000 ( 29.578987)
|
80
|
+
get-large:stash 5.430000 2.020000 7.450000 ( 11.967011)
|
81
|
+
set-ruby:libm 1.800000 1.990000 3.790000 ( 9.511387)
|
82
|
+
set-ruby:libm:binary 1.610000 2.000000 3.610000 ( 8.502297)
|
83
|
+
set-ruby:libm:noblock 0.910000 0.200000 1.110000 ( 2.083001)
|
84
|
+
set-ruby:libm:noblock_binary 0.750000 0.210000 0.960000 ( 1.895510)
|
85
|
+
set-ruby:libm:udp 1.530000 1.170000 2.700000 ( 6.148442)
|
86
|
+
set-ruby:ruby 16.290000 6.400000 22.690000 ( 23.672254)
|
87
|
+
set-ruby:stash 5.570000 2.020000 7.590000 ( 13.381661)
|
88
|
+
get-ruby:libm 1.920000 1.950000 3.870000 ( 9.042716)
|
89
|
+
get-ruby:libm:binary 1.640000 1.980000 3.620000 ( 7.987886)
|
90
|
+
get-ruby:libm:noblock 2.140000 2.600000 4.740000 ( 10.280036)
|
91
|
+
get-ruby:libm:noblock_binary 1.870000 2.590000 4.460000 ( 9.213013)
|
92
|
+
get-ruby:libm:udp 1.660000 1.170000 2.830000 ( 5.762381)
|
93
|
+
get-ruby:ruby 19.760000 6.500000 26.260000 ( 27.573109)
|
94
|
+
get-ruby:stash 5.480000 2.010000 7.490000 ( 12.349059)
|
95
|
+
set-ruby-large:libm 33.820000 2.340000 36.160000 ( 43.061537)
|
96
|
+
set-ruby-large:libm:binary 33.430000 2.260000 35.690000 ( 41.940845)
|
97
|
+
set-ruby-large:libm:noblock 34.170000 0.930000 35.100000 ( 35.632694)
|
98
|
+
set-ruby-large:libm:noblock_binary 34.010000 0.930000 34.940000 ( 35.383141)
|
99
|
+
set-ruby-large:libm:udp 33.150000 1.430000 34.580000 ( 39.521448)
|
100
|
+
set-ruby-large:ruby 48.830000 6.560000 55.390000 ( 55.750071)
|
101
|
+
set-ruby-large:stash 38.660000 2.230000 40.890000 ( 46.957838)
|
102
|
+
get-ruby-large:libm 23.570000 2.340000 25.910000 ( 32.166590)
|
103
|
+
get-ruby-large:libm:binary 23.420000 2.510000 25.930000 ( 31.953854)
|
104
|
+
get-ruby-large:libm:noblock 23.840000 3.040000 26.880000 ( 32.919639)
|
105
|
+
get-ruby-large:libm:noblock_binary 23.570000 2.970000 26.540000 ( 32.210027)
|
106
|
+
get-ruby-large:libm:udp 23.210000 1.460000 24.670000 ( 29.284808)
|
107
|
+
get-ruby-large:ruby 41.170000 7.560000 48.730000 ( 49.507358)
|
108
|
+
get-ruby-large:stash 25.760000 2.540000 28.300000 ( 33.998493)
|
109
|
+
hash:fnv1a_64 0.240000 0.000000 0.240000 ( 0.247813)
|
110
|
+
hash:murmur 0.190000 0.000000 0.190000 ( 0.193039)
|
111
|
+
hash:default 0.220000 0.000000 0.220000 ( 0.216573)
|
112
|
+
hash:jenkins 0.220000 0.000000 0.220000 ( 0.222694)
|
113
|
+
hash:md5 0.390000 0.000000 0.390000 ( 0.395159)
|
114
|
+
hash:crc 0.210000 0.000000 0.210000 ( 0.216457)
|
115
|
+
hash:hsieh 0.100000 0.000000 0.100000 ( 0.104386)
|
116
|
+
hash:fnv1_32 0.220000 0.000000 0.220000 ( 0.216769)
|
117
|
+
hash:fnv1a_32 0.230000 0.000000 0.230000 ( 0.237016)
|
118
|
+
hash:fnv1_64 0.450000 0.010000 0.460000 ( 0.454704)
|
119
|
+
|
120
|
+
|
data/CHANGELOG
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
|
2
|
+
v0.17.4. Don't segfault on invalid keys in get_multi.
|
3
|
+
|
4
|
+
v0.17.3. Compile with -Os. Retry once on Memcached::ClientError.
|
5
|
+
|
6
|
+
v0.17.2. Fix realloc bug on Linux that got regressed.
|
7
|
+
|
8
|
+
v0.17.1. Ruby 1.9 compatibility.
|
9
|
+
|
10
|
+
v0.17. Update to libmemcached 0.32. Update Darwin version string for Snow Leopard final. Improve benchmarks. Add Memcached::Rails#append and #prepend, alias all original Memcached methods to _orig, and add set_servers= accessor for compatibility.
|
11
|
+
|
12
|
+
v0.16.3. Optimize append/prepend on miss.
|
13
|
+
|
14
|
+
v0.16.2. Fix memory leak.
|
15
|
+
|
16
|
+
v0.16.1. Use seeded random. Fix realloc bug on Linux.
|
17
|
+
|
18
|
+
v0.16. Build properly on OS X Snow Leopard.
|
19
|
+
|
20
|
+
v0.15.3. UDP fix. 0-value fix. Enforce server_add response code. Better tests.
|
21
|
+
|
22
|
+
v0.15.2. Don't require memcached itself to build. Fix for AUTO_EJECT_HOSTS in random and modulus pools. Support binary protocol.
|
23
|
+
|
24
|
+
v0.15.1. Fix build problem.
|
25
|
+
|
26
|
+
v0.15. Update to libmemcached 0.31.1. UDP support. Domain socket support (hellvinz). Bugfixes. Bundle libmemcached itself with the gem (antifuchs).
|
27
|
+
|
28
|
+
v0.14.4. Re-SWIG.
|
29
|
+
|
30
|
+
v0.14.3. Change Rails#get_multi API.
|
31
|
+
|
32
|
+
v0.14.2. Update to libmemcached 0.26.2. Return errno description.
|
33
|
+
|
34
|
+
v0.14.1. Update to libmemcached 0.26.1. Various bugfixes. Expose memcached_generate_hash_rvalue.
|
35
|
+
|
36
|
+
v0.13. Update to libmemcached 0.25. Use new built-in failover. Document fixed timeouts.
|
37
|
+
|
38
|
+
v0.12. Update to libmemcached 0.24. Support weights and flags. Default to HASH_WITH_PREFIX behavior. Note, if you use ketama, upgrading will invalidate your entire cache.
|
39
|
+
|
40
|
+
v0.11. Update to libmemcached 0.22. Support hostname lookups. Register %freefunc for MemcachedSt and remove destroy() method. Use new built-in behavior for namespacing. Raise on version mismatch. Remove private hash function. Fix bug related to socket size behavior reset when struct is initialized with missing servers (Jeffrey Hardy). Note, if you use a namespace, upgrading will invalidate your entire cache.
|
41
|
+
|
42
|
+
v0.10. Update to libmemcached 0.20. Failover support. Close consistent hashing bugs.
|
43
|
+
|
44
|
+
v0.9. Update to libmemcached 0.19. Add some failover tests, but we are still waiting on libmemcached's replication branch for them to actually be useful. Fix CAS bug (ktheory).
|
45
|
+
|
46
|
+
v0.8.1. Disable NotFound backtraces for speed (Blaine Cook).
|
47
|
+
|
48
|
+
v0.8. CAS support. Update to libmemcached 0.16.
|
49
|
+
|
50
|
+
v0.7.2. Auto-repair unprintable characters and too-long keys; improve performance of namespacing operation.
|
51
|
+
|
52
|
+
v0.7.1. Allow for explicit resetting of the struct on each request, at least until Brian fixes the synchronization problem.
|
53
|
+
|
54
|
+
v0.7. Rails compatibility wrapper; real multiget; rescue UnknownReadFailures in order to reset the struct..
|
55
|
+
|
56
|
+
v0.6. Better documentation; benchmark suite; improve buffered IO API; remove namespace accessor in favor of generic options hash; patch up extconf.rb to handle unusual library situations; increase test coverage.
|
57
|
+
|
58
|
+
v0.5. First release.
|
data/LICENSE
ADDED
@@ -0,0 +1,184 @@
|
|
1
|
+
Academic Free License (AFL) v. 3.0
|
2
|
+
|
3
|
+
This Academic Free License (the "License") applies to any original work
|
4
|
+
of authorship (the "Original Work") whose owner (the "Licensor") has
|
5
|
+
placed the following licensing notice adjacent to the copyright notice
|
6
|
+
for the Original Work:
|
7
|
+
|
8
|
+
Licensed under the Academic Free License version 3.0
|
9
|
+
|
10
|
+
1) Grant of Copyright License. Licensor grants You a worldwide,
|
11
|
+
royalty-free, non-exclusive, sublicensable license, for the duration of
|
12
|
+
the copyright, to do the following:
|
13
|
+
|
14
|
+
a) to reproduce the Original Work in copies, either alone or as part of
|
15
|
+
a collective work;
|
16
|
+
|
17
|
+
b) to translate, adapt, alter, transform, modify, or arrange the
|
18
|
+
Original Work, thereby creating derivative works ("Derivative Works")
|
19
|
+
based upon the Original Work;
|
20
|
+
|
21
|
+
c) to distribute or communicate copies of the Original Work and
|
22
|
+
Derivative Works to the public, under any license of your choice that
|
23
|
+
does not contradict the terms and conditions, including Licensor's
|
24
|
+
reserved rights and remedies, in this Academic Free License;
|
25
|
+
|
26
|
+
d) to perform the Original Work publicly; and
|
27
|
+
|
28
|
+
e) to display the Original Work publicly.
|
29
|
+
|
30
|
+
2) Grant of Patent License. Licensor grants You a worldwide,
|
31
|
+
royalty-free, non-exclusive, sublicensable license, under patent claims
|
32
|
+
owned or controlled by the Licensor that are embodied in the Original
|
33
|
+
Work as furnished by the Licensor, for the duration of the patents, to
|
34
|
+
make, use, sell, offer for sale, have made, and import the Original Work
|
35
|
+
and Derivative Works.
|
36
|
+
|
37
|
+
3) Grant of Source Code License. The term "Source Code" means the
|
38
|
+
preferred form of the Original Work for making modifications to it and
|
39
|
+
all available documentation describing how to modify the Original Work.
|
40
|
+
Licensor agrees to provide a machine-readable copy of the Source Code of
|
41
|
+
the Original Work along with each copy of the Original Work that
|
42
|
+
Licensor distributes. Licensor reserves the right to satisfy this
|
43
|
+
obligation by placing a machine-readable copy of the Source Code in an
|
44
|
+
information repository reasonably calculated to permit inexpensive and
|
45
|
+
convenient access by You for as long as Licensor continues to distribute
|
46
|
+
the Original Work.
|
47
|
+
|
48
|
+
4) Exclusions From License Grant. Neither the names of Licensor, nor the
|
49
|
+
names of any contributors to the Original Work, nor any of their
|
50
|
+
trademarks or service marks, may be used to endorse or promote products
|
51
|
+
derived from this Original Work without express prior permission of the
|
52
|
+
Licensor. Except as expressly stated herein, nothing in this License
|
53
|
+
grants any license to Licensor's trademarks, copyrights, patents, trade
|
54
|
+
secrets or any other intellectual property. No patent license is granted
|
55
|
+
to make, use, sell, offer for sale, have made, or import embodiments of
|
56
|
+
any patent claims other than the licensed claims defined in Section 2.
|
57
|
+
No license is granted to the trademarks of Licensor even if such marks
|
58
|
+
are included in the Original Work. Nothing in this License shall be
|
59
|
+
interpreted to prohibit Licensor from licensing under terms different
|
60
|
+
from this License any Original Work that Licensor otherwise would have a
|
61
|
+
right to license.
|
62
|
+
|
63
|
+
5) External Deployment. The term "External Deployment" means the use,
|
64
|
+
distribution, or communication of the Original Work or Derivative Works
|
65
|
+
in any way such that the Original Work or Derivative Works may be used
|
66
|
+
by anyone other than You, whether those works are distributed or
|
67
|
+
communicated to those persons or made available as an application
|
68
|
+
intended for use over a network. As an express condition for the grants
|
69
|
+
of license hereunder, You must treat any External Deployment by You of
|
70
|
+
the Original Work or a Derivative Work as a distribution under section
|
71
|
+
1(c).
|
72
|
+
|
73
|
+
6) Attribution Rights. You must retain, in the Source Code of any
|
74
|
+
Derivative Works that You create, all copyright, patent, or trademark
|
75
|
+
notices from the Source Code of the Original Work, as well as any
|
76
|
+
notices of licensing and any descriptive text identified therein as an
|
77
|
+
"Attribution Notice." You must cause the Source Code for any Derivative
|
78
|
+
Works that You create to carry a prominent Attribution Notice reasonably
|
79
|
+
calculated to inform recipients that You have modified the Original
|
80
|
+
Work.
|
81
|
+
|
82
|
+
7) Warranty of Provenance and Disclaimer of Warranty. Licensor warrants
|
83
|
+
that the copyright in and to the Original Work and the patent rights
|
84
|
+
granted herein by Licensor are owned by the Licensor or are sublicensed
|
85
|
+
to You under the terms of this License with the permission of the
|
86
|
+
contributor(s) of those copyrights and patent rights. Except as
|
87
|
+
expressly stated in the immediately preceding sentence, the Original
|
88
|
+
Work is provided under this License on an "AS IS" BASIS and WITHOUT
|
89
|
+
WARRANTY, either express or implied, including, without limitation, the
|
90
|
+
warranties of non-infringement, merchantability or fitness for a
|
91
|
+
particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL
|
92
|
+
WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential
|
93
|
+
part of this License. No license to the Original Work is granted by this
|
94
|
+
License except under this disclaimer.
|
95
|
+
|
96
|
+
8) Limitation of Liability. Under no circumstances and under no legal
|
97
|
+
theory, whether in tort (including negligence), contract, or otherwise,
|
98
|
+
shall the Licensor be liable to anyone for any indirect, special,
|
99
|
+
incidental, or consequential damages of any character arising as a
|
100
|
+
result of this License or the use of the Original Work including,
|
101
|
+
without limitation, damages for loss of goodwill, work stoppage,
|
102
|
+
computer failure or malfunction, or any and all other commercial damages
|
103
|
+
or losses. This limitation of liability shall not apply to the extent
|
104
|
+
applicable law prohibits such limitation.
|
105
|
+
|
106
|
+
9) Acceptance and Termination. If, at any time, You expressly assented
|
107
|
+
to this License, that assent indicates your clear and irrevocable
|
108
|
+
acceptance of this License and all of its terms and conditions. If You
|
109
|
+
distribute or communicate copies of the Original Work or a Derivative
|
110
|
+
Work, You must make a reasonable effort under the circumstances to
|
111
|
+
obtain the express assent of recipients to the terms of this License.
|
112
|
+
This License conditions your rights to undertake the activities listed
|
113
|
+
in Section 1, including your right to create Derivative Works based upon
|
114
|
+
the Original Work, and doing so without honoring these terms and
|
115
|
+
conditions is prohibited by copyright law and international treaty.
|
116
|
+
Nothing in this License is intended to affect copyright exceptions and
|
117
|
+
limitations (including "fair use" or "fair dealing"). This License shall
|
118
|
+
terminate immediately and You may no longer exercise any of the rights
|
119
|
+
granted to You by this License upon your failure to honor the conditions
|
120
|
+
in Section 1(c).
|
121
|
+
|
122
|
+
10) Termination for Patent Action. This License shall terminate
|
123
|
+
automatically and You may no longer exercise any of the rights granted
|
124
|
+
to You by this License as of the date You commence an action, including
|
125
|
+
a cross-claim or counterclaim, against Licensor or any licensee alleging
|
126
|
+
that the Original Work infringes a patent. This termination provision
|
127
|
+
shall not apply for an action alleging patent infringement by
|
128
|
+
combinations of the Original Work with other software or hardware.
|
129
|
+
|
130
|
+
11) Jurisdiction, Venue and Governing Law. Any action or suit relating
|
131
|
+
to this License may be brought only in the courts of a jurisdiction
|
132
|
+
wherein the Licensor resides or in which Licensor conducts its primary
|
133
|
+
business, and under the laws of that jurisdiction excluding its
|
134
|
+
conflict-of-law provisions. The application of the United Nations
|
135
|
+
Convention on Contracts for the International Sale of Goods is expressly
|
136
|
+
excluded. Any use of the Original Work outside the scope of this License
|
137
|
+
or after its termination shall be subject to the requirements and
|
138
|
+
penalties of copyright or patent law in the appropriate jurisdiction.
|
139
|
+
This section shall survive the termination of this License.
|
140
|
+
|
141
|
+
12) Attorneys' Fees. In any action to enforce the terms of this License
|
142
|
+
or seeking damages relating thereto, the prevailing party shall be
|
143
|
+
entitled to recover its costs and expenses, including, without
|
144
|
+
limitation, reasonable attorneys' fees and costs incurred in connection
|
145
|
+
with such action, including any appeal of such action. This section
|
146
|
+
shall survive the termination of this License.
|
147
|
+
|
148
|
+
13) Miscellaneous. If any provision of this License is held to be
|
149
|
+
unenforceable, such provision shall be reformed only to the extent
|
150
|
+
necessary to make it enforceable.
|
151
|
+
|
152
|
+
14) Definition of "You" in This License. "You" throughout this License,
|
153
|
+
whether in upper or lower case, means an individual or a legal entity
|
154
|
+
exercising rights under, and complying with all of the terms of, this
|
155
|
+
License. For legal entities, "You" includes any entity that controls, is
|
156
|
+
controlled by, or is under common control with you. For purposes of this
|
157
|
+
definition, "control" means (i) the power, direct or indirect, to cause
|
158
|
+
the direction or management of such entity, whether by contract or
|
159
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
160
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
161
|
+
|
162
|
+
15) Right to Use. You may use the Original Work in all ways not
|
163
|
+
otherwise restricted or conditioned by this License or by law, and
|
164
|
+
Licensor promises not to interfere with or be responsible for such uses
|
165
|
+
by You.
|
166
|
+
|
167
|
+
16) Modification of This License. This License is Copyright (c) 2005
|
168
|
+
Lawrence Rosen. Permission is granted to copy, distribute, or
|
169
|
+
communicate this License without modification. Nothing in this License
|
170
|
+
permits You to modify this License as applied to the Original Work or to
|
171
|
+
Derivative Works. However, You may modify the text of this License and
|
172
|
+
copy, distribute or communicate your modified version (the "Modified
|
173
|
+
License") and apply it to other original works of authorship subject to
|
174
|
+
the following conditions: (i) You may not indicate in any way that your
|
175
|
+
Modified License is the "Academic Free License" or "AFL" and you may not
|
176
|
+
use those names in the name of your Modified License; (ii) You must
|
177
|
+
replace the notice specified in the first paragraph above with the
|
178
|
+
notice "Licensed under <insert your license name here>" or with a notice
|
179
|
+
of your own that is not confusingly similar to the notice in this
|
180
|
+
License; and (iii) You may not claim that your original works are open
|
181
|
+
source software unless your Modified License has been approved by Open
|
182
|
+
Source Initiative (OSI) and You comply with its license review and
|
183
|
+
certification process.
|
184
|
+
|
data/Manifest
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
BENCHMARKS
|
2
|
+
CHANGELOG
|
3
|
+
LICENSE
|
4
|
+
Manifest
|
5
|
+
README
|
6
|
+
Rakefile
|
7
|
+
TODO
|
8
|
+
ext/extconf.rb
|
9
|
+
ext/libmemcached-0.32.tar.gz
|
10
|
+
ext/libmemcached.patch
|
11
|
+
ext/rlibmemcached.i
|
12
|
+
ext/rlibmemcached_wrap.c
|
13
|
+
lib/memcached.rb
|
14
|
+
lib/memcached/behaviors.rb
|
15
|
+
lib/memcached/exceptions.rb
|
16
|
+
lib/memcached/integer.rb
|
17
|
+
lib/memcached/memcached.rb
|
18
|
+
lib/memcached/rails.rb
|
19
|
+
test/profile/benchmark.rb
|
20
|
+
test/profile/profile.rb
|
21
|
+
test/profile/valgrind.rb
|
22
|
+
test/setup.rb
|
23
|
+
test/teardown.rb
|
24
|
+
test/test_helper.rb
|
25
|
+
test/unit/binding_test.rb
|
26
|
+
test/unit/memcached_test.rb
|
27
|
+
test/unit/rails_test.rb
|
data/README
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
NOTES ON THIS FORK
|
2
|
+
==================
|
3
|
+
* This fork adds #big_get and #big_set methods that allow for items bigger than the 1MB memcached value limit.
|
4
|
+
* Thanks to jf http://github.com/jf/memcached for the original idea and contributions:
|
5
|
+
http://github.com/jf/memcached/commit/a206663e06917c11981b4cdad119bff8cdd2d5cb
|
6
|
+
http://github.com/jf/memcached/commit/a94ccddc66081d52b85460b76720bbf2800e4435
|
7
|
+
|
8
|
+
|
9
|
+
memcached
|
10
|
+
|
11
|
+
An interface to the libmemcached C client.
|
12
|
+
|
13
|
+
== License
|
14
|
+
|
15
|
+
Copyright 2009 Cloudburst, LLC. Licensed under the AFL 3. See the included LICENSE file. Portions copyright 2007-2009 TangentOrg, Brian Aker, licensed under the BSD license, and used with permission.
|
16
|
+
|
17
|
+
The public certificate for this gem is here[http://rubyforge.org/frs/download.php/25331/evan_weaver-original-public_cert.pem].
|
18
|
+
|
19
|
+
If you use this software, please {make a donation}[http://blog.evanweaver.com/donate/], or {recommend Evan}[http://www.workingwithrails.com/person/7739-evan-weaver] at Working with Rails.
|
20
|
+
|
21
|
+
== Features
|
22
|
+
|
23
|
+
* clean API
|
24
|
+
* robust access to all memcached features
|
25
|
+
* multiple hashing modes, including consistent hashing
|
26
|
+
* ludicrous speed, including optional non-blocking IO
|
27
|
+
|
28
|
+
The <b>memcached</b> library wraps the pure-C libmemcached client via SWIG.
|
29
|
+
|
30
|
+
== Installation
|
31
|
+
|
32
|
+
You need Ruby 1.8.7 or Ruby 1.9.1. Other versions may work, but are not guaranteed. You also need {memcached itself}[http://www.danga.com/memcached/] if you want to test against a local server.
|
33
|
+
|
34
|
+
Install the gem:
|
35
|
+
sudo gem install memcached --no-rdoc --no-ri
|
36
|
+
|
37
|
+
== Usage
|
38
|
+
|
39
|
+
Start a local networked memcached server:
|
40
|
+
$ memcached -p 11211 &
|
41
|
+
|
42
|
+
Now, in Ruby, require the library and instantiate a Memcached object at a global level:
|
43
|
+
|
44
|
+
require 'memcached'
|
45
|
+
$cache = Memcached.new("localhost:11211")
|
46
|
+
|
47
|
+
Now you can set things and get things:
|
48
|
+
|
49
|
+
value = 'hello'
|
50
|
+
$cache.set 'test', value
|
51
|
+
$cache.get 'test' #=> "hello"
|
52
|
+
|
53
|
+
You can set with an expiration timeout:
|
54
|
+
|
55
|
+
value = 'hello'
|
56
|
+
$cache.set 'test', value, 1
|
57
|
+
sleep(2)
|
58
|
+
$cache.get 'test' #=> raises Memcached::NotFound
|
59
|
+
|
60
|
+
You can get multiple values at once:
|
61
|
+
|
62
|
+
value = 'hello'
|
63
|
+
$cache.set 'test', value
|
64
|
+
$cache.set 'test2', value
|
65
|
+
$cache.get ['test', 'test2', 'missing']
|
66
|
+
#=> {"test" => "hello", "test2" => "hello"}
|
67
|
+
|
68
|
+
You can set a counter and increment it:
|
69
|
+
|
70
|
+
start = 1
|
71
|
+
$cache.set 'counter', start, 0, false
|
72
|
+
$cache.increment 'counter' #=> 2
|
73
|
+
$cache.increment 'counter' #=> 3
|
74
|
+
$cache.get('counter', false).to_i #=> 3
|
75
|
+
|
76
|
+
You can get some server stats:
|
77
|
+
|
78
|
+
$cache.stats #=> {..., :bytes_written=>[62], :version=>["1.2.4"] ...}
|
79
|
+
|
80
|
+
Note that the API is not the same as that of <b>Ruby-MemCache</b> or <b>memcache-client</b>. In particular, <tt>nil</tt> is a valid record value. Memcached#get does not return <tt>nil</tt> on failure, rather it raises <b>Memcached::NotFound</b>. This is consistent with the behavior of memcached itself. For example:
|
81
|
+
|
82
|
+
$cache.set 'test', nil
|
83
|
+
$cache.get 'test' #=> nil
|
84
|
+
$cache.delete 'test'
|
85
|
+
$cache.get 'test' #=> raises Memcached::NotFound
|
86
|
+
|
87
|
+
== Legacy applications
|
88
|
+
|
89
|
+
There is a compatibility wrapper for legacy applications called Memcached::Rails.
|
90
|
+
|
91
|
+
== Threading
|
92
|
+
|
93
|
+
<b>memcached</b> is threadsafe, but each thread requires its own Memcached instance. Create a global Memcached, and then call Memcached#clone each time you spawn a thread.
|
94
|
+
|
95
|
+
thread = Thread.new do
|
96
|
+
cache = $cache.clone
|
97
|
+
# Perform operations on cache, not $cache
|
98
|
+
cache.set 'example', 1
|
99
|
+
cache.get 'example'
|
100
|
+
end
|
101
|
+
|
102
|
+
# Join the thread so that exceptions don't get lost
|
103
|
+
thread.join
|
104
|
+
|
105
|
+
== Benchmarks
|
106
|
+
|
107
|
+
<b>memcached</b> is up to 10x faster than <b>memcache-client</b>. See BENCHMARKS[link:files/BENCHMARKS.html] for details.
|
108
|
+
|
109
|
+
== Reporting problems
|
110
|
+
|
111
|
+
The support forum is here[http://rubyforge.org/forum/forum.php?forum_id=20894].
|
112
|
+
|
113
|
+
Patches and contributions are very welcome. Please note that contributors are required to assign copyright for their additions to Cloudburst, LLC.
|
114
|
+
|
115
|
+
== Further resources
|
116
|
+
|
117
|
+
* {Memcached wiki}[http://www.socialtext.net/memcached/index.cgi]
|
118
|
+
* {Libmemcached homepage}[http://tangent.org/552/libmemcached.html]
|