mcmire-cache 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +7 -0
- data/CHANGELOG +21 -0
- data/Gemfile +22 -0
- data/README.md +229 -0
- data/Rakefile +41 -0
- data/benchmarks/afterrefactor.txt +86 -0
- data/benchmarks/midrefactor.txt +89 -0
- data/benchmarks/v0.0.2.txt +95 -0
- data/benchmarks/v0.0.3.txt +96 -0
- data/benchmarks/v0.1.2.txt +94 -0
- data/benchmarks/v0.2.1.txt +94 -0
- data/benchmarks/v0.2.2.txt +94 -0
- data/lib/cache.rb +233 -0
- data/lib/cache/active_support_cache_dalli_store.rb +15 -0
- data/lib/cache/active_support_cache_file_store.rb +11 -0
- data/lib/cache/active_support_cache_memory_store.rb +11 -0
- data/lib/cache/active_support_cache_store.rb +37 -0
- data/lib/cache/config.rb +27 -0
- data/lib/cache/dalli_client.rb +54 -0
- data/lib/cache/mem_cache.rb +46 -0
- data/lib/cache/memcached.rb +54 -0
- data/lib/cache/memcached_rails.rb +34 -0
- data/lib/cache/nothing.rb +20 -0
- data/lib/cache/redis.rb +44 -0
- data/lib/cache/redis_namespace.rb +7 -0
- data/lib/cache/version.rb +3 -0
- data/mcmire-cache.gemspec +22 -0
- data/test/helper.rb +29 -0
- data/test/profile/benchmark.rb +258 -0
- data/test/shared_tests.rb +169 -0
- data/test/test_active_support_cache_dalli_store.rb +77 -0
- data/test/test_active_support_cache_file_store.rb +19 -0
- data/test/test_active_support_cache_memory_store.rb +12 -0
- data/test/test_dalli_client.rb +70 -0
- data/test/test_mem_cache.rb +64 -0
- data/test/test_memcached.rb +64 -0
- data/test/test_memcached_rails.rb +61 -0
- data/test/test_memcached_with_binary.rb +17 -0
- data/test/test_missing_driver.rb +16 -0
- data/test/test_nothing.rb +147 -0
- data/test/test_redis.rb +60 -0
- data/test/test_redis_namespace.rb +64 -0
- metadata +108 -0
data/.gitignore
ADDED
data/CHANGELOG
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
0.3.3 / 2012-04-17
|
2
|
+
|
3
|
+
* Enhancements
|
4
|
+
|
5
|
+
* Test on MRI 1.8, MRI 1.9, and JRuby 1.6.7+
|
6
|
+
|
7
|
+
* Bug fixes
|
8
|
+
|
9
|
+
* Fix Redis support. Tests were silently failing, made them loud and then fixed 'em.
|
10
|
+
|
11
|
+
0.3.2 / 2012-04-11
|
12
|
+
|
13
|
+
* Enhancements
|
14
|
+
|
15
|
+
* Compatibility with Rails 3.2.x that uses ActiveSupport::Cache::FileStore
|
16
|
+
|
17
|
+
0.3.1 / 2012-04-10
|
18
|
+
|
19
|
+
* Bug fixes
|
20
|
+
|
21
|
+
* Compatibility with Rails 2.x that calls Rails.cache.logger=
|
data/Gemfile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
source :rubygems
|
2
|
+
|
3
|
+
# Production dependencies
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
# Development dependencies
|
7
|
+
|
8
|
+
gem 'yard', '~> 0.8'
|
9
|
+
gem 'test-unit', '~> 2.5'
|
10
|
+
|
11
|
+
gem 'activesupport', '>= 2.3.11'
|
12
|
+
gem 'i18n'
|
13
|
+
|
14
|
+
gem 'redis', '~> 3.0'
|
15
|
+
gem 'redis-namespace', '~> 1.2'
|
16
|
+
gem 'dalli', '~> 2.1'
|
17
|
+
unless RUBY_PLATFORM == 'java'
|
18
|
+
gem 'memcached', '~> 1.4'
|
19
|
+
end
|
20
|
+
gem 'memcache-client', '~> 1.8'
|
21
|
+
gem 'rake'
|
22
|
+
gem 'rack', '~> 1.4' # for ActiveSupport::Cache::FileStore of all things
|
data/README.md
ADDED
@@ -0,0 +1,229 @@
|
|
1
|
+
# cache
|
2
|
+
|
3
|
+
Wraps memcached, redis, memcache-client, dalli and handles their weirdnesses, including forking.
|
4
|
+
|
5
|
+
Aims to let other libraries be cache-agnostic in return for a performance hit.
|
6
|
+
|
7
|
+
## Real world usage
|
8
|
+
|
9
|
+
Used by [lock_method](https://github.com/seamusabshere/lock_method) and [cache_method](https://github.com/seamusabshere/cache_method) so that you can use them with memcached, redis, etc.
|
10
|
+
|
11
|
+
In production use at [carbon.brighterplanet.com](http://carbon.brighterplanet.com) and [data.brighterplanet.com](http://data.brighterplanet.com).
|
12
|
+
|
13
|
+
## Quick example
|
14
|
+
|
15
|
+
require 'memcached' # a really fast memcached client gem by Evan Weaver, one of the lead engineers at Twitter
|
16
|
+
require 'cache' # this gem, which wraps the client to provide a standard interface
|
17
|
+
|
18
|
+
client = Memcached.new('127.0.0.1:11211', :binary_protocol => true)
|
19
|
+
@cache = Cache.wrap(client)
|
20
|
+
|
21
|
+
# don't worry, even though it's memcached gem, this won't raise Memcached::NotFound
|
22
|
+
@cache.get('hello')
|
23
|
+
|
24
|
+
# fetch is not provided by the memcached gem, the wrapper adds it
|
25
|
+
@cache.fetch('hello') { 'world' }
|
26
|
+
|
27
|
+
# don't worry, the wrapper will automatically clone the Memcached object after forking (or threading for that matter)
|
28
|
+
Kernel.fork { @cache.get('hello') }
|
29
|
+
|
30
|
+
If you can't use the memcached gem (because you're on heroku, for example) then just wrap a dalli or a redis client. You still get exactly the same interface.
|
31
|
+
|
32
|
+
## Rationale
|
33
|
+
|
34
|
+
I wanted a common interface to a bunch of great Ruby cache clients so I can develop gems ([lock_method](https://github.com/seamusabshere/lock_method), [cache_method](https://github.com/seamusabshere/cache_method)) that accept any of them.
|
35
|
+
|
36
|
+
* I'm tired of rescuing from Memcached::NotFound
|
37
|
+
* I'm tired of forgetting whether it's :expires_in or :ttl
|
38
|
+
* I don't know why we ever started using read/write instead of get/set.
|
39
|
+
* I don't like how you have to manually handle after_fork for Redis, Memcached, etc.
|
40
|
+
* I don't know why Memcached::Rails doesn't act like a ActiveRecord::Cache::Store
|
41
|
+
* Why are you asking me about :raw or whatever? Just marshal it
|
42
|
+
|
43
|
+
## Speed
|
44
|
+
|
45
|
+
It's more than 50% slower than raw [Memcached](https://github.com/evan/memcached) and about the same as raw [Dalli](https://github.com/mperham/dalli)
|
46
|
+
|
47
|
+
# raw dalli versus wrapped
|
48
|
+
|
49
|
+
set: cache:dalli:bin 2.150000 0.840000 2.990000 ( 3.752008) <- Cache.wrap(Dalli::Client.new)
|
50
|
+
set: dalli:bin 2.120000 0.830000 2.950000 ( 3.734024) <- Dalli::Client.new
|
51
|
+
|
52
|
+
get: cache:dalli:bin 2.040000 0.910000 2.950000 ( 3.646148)
|
53
|
+
get: dalli:bin 2.040000 0.900000 2.940000 ( 3.632840)
|
54
|
+
|
55
|
+
delete: cache:dalli:bin 1.830000 0.880000 2.710000 ( 3.381917)
|
56
|
+
delete: dalli:bin 1.790000 0.880000 2.670000 ( 3.327514)
|
57
|
+
|
58
|
+
get-missing: cache:dalli:bin 1.780000 0.880000 2.660000 ( 3.344041)
|
59
|
+
get-missing: dalli:bin 1.760000 0.880000 2.640000 ( 3.337539)
|
60
|
+
|
61
|
+
set-large: cache:dalli:bin 2.750000 0.880000 3.630000 ( 4.474265)
|
62
|
+
set-large: dalli:bin 2.720000 0.870000 3.590000 ( 4.436163)
|
63
|
+
|
64
|
+
get-large: cache:dalli:bin 2.420000 0.990000 3.410000 ( 4.135326)
|
65
|
+
get-large: dalli:bin 2.410000 0.990000 3.400000 ( 4.119832)
|
66
|
+
|
67
|
+
# raw memcached versus wrapped
|
68
|
+
|
69
|
+
set: cache:libm:bin 0.860000 0.640000 1.500000 ( 3.033145) <- Cache.wrap(Memcached.new(:binary_protocol => true))
|
70
|
+
set: libm:bin 0.200000 0.480000 0.680000 ( 1.907099) <- Memcached.new(:binary_protocol => true)
|
71
|
+
|
72
|
+
get: cache:libm:bin 0.800000 0.680000 1.480000 ( 2.700458)
|
73
|
+
get: libm:bin 0.260000 0.660000 0.920000 ( 1.974025)
|
74
|
+
|
75
|
+
delete: cache:libm:bin 1.000000 0.600000 1.600000 ( 2.968057)
|
76
|
+
delete: libm:bin 0.600000 0.560000 1.160000 ( 2.375070)
|
77
|
+
|
78
|
+
get-missing: cache:libm:bin 0.980000 0.800000 1.780000 ( 2.850947)
|
79
|
+
get-missing: libm:bin 0.640000 0.710000 1.350000 ( 2.520733)
|
80
|
+
|
81
|
+
set-large: cache:libm:bin 1.220000 0.590000 1.810000 ( 3.404739)
|
82
|
+
set-large: libm:bin 0.230000 0.520000 0.750000 ( 2.111738)
|
83
|
+
|
84
|
+
get-large: cache:libm:bin 3.780000 0.870000 4.650000 ( 6.073208)
|
85
|
+
get-large: libm:bin 0.340000 0.830000 1.170000 ( 2.304408)
|
86
|
+
|
87
|
+
Thanks to https://github.com/evan/memcached/blob/master/test/profile/benchmark.rb
|
88
|
+
|
89
|
+
So: hopefully it makes it easier to get started with caching and hit the low-hanging fruit. Then you can move on to a raw client!
|
90
|
+
|
91
|
+
## Features
|
92
|
+
|
93
|
+
### Forking/threading
|
94
|
+
|
95
|
+
When you use a Cache object to wrap Memcached or Redis, you don't have to worry about forking or threading.
|
96
|
+
|
97
|
+
For example, you don't have to set up unicorn or PhusionPassenger's <tt>after_fork</tt>.
|
98
|
+
|
99
|
+
### TTL
|
100
|
+
|
101
|
+
0 means don't expire.
|
102
|
+
|
103
|
+
The default ttl is 60 seconds.
|
104
|
+
|
105
|
+
### Marshalling
|
106
|
+
|
107
|
+
Everything gets marshalled. No option to turn it into "raw" mode. If you need that kind of control, please submit a patch or just use one of the other gems directly.
|
108
|
+
|
109
|
+
### Methods
|
110
|
+
|
111
|
+
It will translate these methods to whatever Redis, Memcached, etc. client you're using:
|
112
|
+
|
113
|
+
@cache.get 'hello'
|
114
|
+
@cache.set 'hello', 'world', 5.minutes
|
115
|
+
@cache.delete 'hello'
|
116
|
+
@cache.flush
|
117
|
+
@cache.exist? 'hello'
|
118
|
+
@cache.reset
|
119
|
+
@cache.fetch 'hello' { 'world' }
|
120
|
+
@cache.cas 'hello' { |current| 'world' }
|
121
|
+
@cache.increment 'high-fives'
|
122
|
+
@cache.decrement 'high-fives'
|
123
|
+
@cache.get_multi 'hello', 'privyet', 'hallo'
|
124
|
+
|
125
|
+
Also provided for Rails compatibility:
|
126
|
+
|
127
|
+
@cache.write 'hello', 'world', :expires_in => 5.minutes
|
128
|
+
@cache.read 'hello'
|
129
|
+
@cache.clear
|
130
|
+
@cache.compare_and_swap
|
131
|
+
@cache.read_multi 'hello', 'privyet', 'hallo'
|
132
|
+
|
133
|
+
## Supported clients
|
134
|
+
|
135
|
+
Supported memcached clients:
|
136
|
+
|
137
|
+
* [memcached](https://github.com/fauna/memcached) ~> 1.4 (native C extensions, super fast!)
|
138
|
+
* [dalli](https://github.com/mperham/dalli) ~> 2.1 (pure ruby, recommended if you're on heroku)
|
139
|
+
* [memcache-client](https://github.com/mperham/memcache-client) ~> 1.8 (not recommended. the one that comes with Rails.)
|
140
|
+
|
141
|
+
Supported Redis clients:
|
142
|
+
|
143
|
+
* [redis](https://github.com/ezmobius/redis-rb) ~> 3.0
|
144
|
+
|
145
|
+
## How you might use it
|
146
|
+
|
147
|
+
<table>
|
148
|
+
<tr>
|
149
|
+
<th> </th>
|
150
|
+
<th><a href="https://github.com/fauna/memcached">Super-fast memcached</a></th>
|
151
|
+
<th><a href="https://github.com/mperham/dalli">Pure Ruby memcached</a> (works on <a href="http://devcenter.heroku.com/articles/memcache">Heroku</a>)</th>
|
152
|
+
<th><a href="https://redistogo.com/">Redis</a></th>
|
153
|
+
</tr>
|
154
|
+
<tr>
|
155
|
+
<td><a href="http://guides.rubyonrails.org/caching_with_rails.html#cache-stores">Rails</a></td>
|
156
|
+
<td><pre>config.cache_store = Cache.wrap(Memcached.new)</pre></td>
|
157
|
+
<td><pre>config.cache_store = Cache.wrap(Dalli::Client.new)</pre></td>
|
158
|
+
<td><pre>config.cache_store = Cache.wrap(Redis.new)</pre></td>
|
159
|
+
</tr>
|
160
|
+
<tr>
|
161
|
+
<td>Your own library</td>
|
162
|
+
<td>
|
163
|
+
<pre>
|
164
|
+
# Accept any client, let Cache take care of it
|
165
|
+
def cache=(raw_client)
|
166
|
+
@cache = Cache.wrap(raw_client)
|
167
|
+
end
|
168
|
+
</pre>
|
169
|
+
</td>
|
170
|
+
<td>
|
171
|
+
<pre>
|
172
|
+
# Accept any client, let Cache take care of it
|
173
|
+
def cache=(raw_client)
|
174
|
+
@cache = Cache.wrap(raw_client)
|
175
|
+
end
|
176
|
+
</pre>
|
177
|
+
</td>
|
178
|
+
<td>
|
179
|
+
<pre>
|
180
|
+
# Accept any client, let Cache take care of it
|
181
|
+
def cache=(raw_client)
|
182
|
+
@cache = Cache.wrap(raw_client)
|
183
|
+
end
|
184
|
+
</pre>
|
185
|
+
</td>
|
186
|
+
</tr>
|
187
|
+
<tr>
|
188
|
+
<td><a href="https://github.com/seamusabshere/cache_method">CacheMethod</a> (already uses Cache internally)</td>
|
189
|
+
<td><pre>CacheMethod.config.storage = Memcached.new</pre></td>
|
190
|
+
<td><pre>CacheMethod.config.storage = Dalli::Client.new</pre></td>
|
191
|
+
<td><pre>CacheMethod.config.storage = Redis.new</pre></td>
|
192
|
+
</tr>
|
193
|
+
<tr>
|
194
|
+
<td><a href="https://github.com/seamusabshere/lock_method">LockMethod</a> (already uses Cache internally)</td>
|
195
|
+
<td><pre>LockMethod.config.storage = Memcached.new</pre></td>
|
196
|
+
<td><pre>LockMethod.config.storage = Dalli::Client.new</pre></td>
|
197
|
+
<td><pre>LockMethod.config.storage = Redis.new</pre></td>
|
198
|
+
</tr>
|
199
|
+
</table>
|
200
|
+
|
201
|
+
## Other examples
|
202
|
+
|
203
|
+
It defaults to an in-process memory store:
|
204
|
+
|
205
|
+
@cache = Cache.new
|
206
|
+
@cache.set 'hello'
|
207
|
+
@cache.get 'hello', 'world'
|
208
|
+
|
209
|
+
You can specify a more useful cache client:
|
210
|
+
|
211
|
+
require 'redis' # the redis key-value store
|
212
|
+
require 'cache' # this gem, which provides a standard interface
|
213
|
+
raw_client = Redis.new
|
214
|
+
@cache = Cache.wrap(raw_client)
|
215
|
+
|
216
|
+
or
|
217
|
+
|
218
|
+
require 'dalli' # the dalli memcached client used by heroku
|
219
|
+
require 'cache' # this gem, which provides a standard interface
|
220
|
+
raw_client = Dalli::Client.new
|
221
|
+
@cache = Cache.wrap(raw_client)
|
222
|
+
|
223
|
+
Or you could piggyback off the default rails cache:
|
224
|
+
|
225
|
+
@cache = Cache.wrap(Rails.cache)
|
226
|
+
|
227
|
+
## Copyright
|
228
|
+
|
229
|
+
Copyright 2011 Seamus Abshere
|
data/Rakefile
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
4
|
+
require 'rake'
|
5
|
+
require 'rake/testtask'
|
6
|
+
Rake::TestTask.new(:test) do |test|
|
7
|
+
test.libs << 'lib' << 'test'
|
8
|
+
test.pattern = 'test/**/test_*.rb'
|
9
|
+
test.verbose = true
|
10
|
+
end
|
11
|
+
|
12
|
+
task :default => :test
|
13
|
+
|
14
|
+
# http://stackoverflow.com/questions/2138427/can-i-get-my-readme-textile-into-my-rdoc-with-proper-formatting
|
15
|
+
desc "Generate RDoc"
|
16
|
+
task :rdoc => ['doc:generate']
|
17
|
+
namespace :doc do
|
18
|
+
project_root = File.expand_path(File.dirname(__FILE__))
|
19
|
+
doc_destination = File.join(project_root, 'rdoc')
|
20
|
+
files = Dir.glob(File.join(project_root, 'lib', '**', '*.rb')) + [ File.join(project_root, 'README.md') ]
|
21
|
+
begin
|
22
|
+
require 'yard'
|
23
|
+
require 'yard/rake/yardoc_task'
|
24
|
+
|
25
|
+
YARD::Rake::YardocTask.new(:generate) do |yt|
|
26
|
+
yt.files = files
|
27
|
+
yt.options = ['--output-dir', doc_destination, '--readme', 'README.md']
|
28
|
+
end
|
29
|
+
rescue LoadError
|
30
|
+
desc "Generate YARD Documentation"
|
31
|
+
task :generate do
|
32
|
+
abort "Please install the YARD gem to generate rdoc."
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
desc "Remove generated documenation"
|
37
|
+
task :clean do
|
38
|
+
rm_r doc_dir if File.exists?(doc_destination)
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
Darwin alzabo0 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:32:41 PDT 2011; root:xnu-1504.15.3~1/RELEASE_X86_64 x86_64
|
2
|
+
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin10.8.0]
|
3
|
+
RUBYOPT=-ropenssl
|
4
|
+
RUBY_VERSION=ruby-1.9.3-p125
|
5
|
+
Ruby 1.9.3p125
|
6
|
+
Loaded memcached 1.4.1
|
7
|
+
Loaded memcache-client 1.8.5
|
8
|
+
Loaded cache 0.2.7
|
9
|
+
Loaded kgio 2.7.4
|
10
|
+
Loaded dalli 2.0.2
|
11
|
+
Loops is 20000
|
12
|
+
Stack depth is 0
|
13
|
+
Small value size is: 19 bytes
|
14
|
+
Large value size is: 4189 bytes
|
15
|
+
user system total real
|
16
|
+
set: cache:dalli:bin 2.140000 0.840000 2.980000 ( 3.750850)
|
17
|
+
set: cache:libm:bin 0.860000 0.630000 1.490000 ( 3.024450)
|
18
|
+
set: dalli:bin 2.120000 0.840000 2.960000 ( 3.727571)
|
19
|
+
set: libm:ascii 0.300000 0.530000 0.830000 ( 2.274182)
|
20
|
+
set: libm:ascii:pipeline 0.110000 0.000000 0.110000 ( 0.111021)
|
21
|
+
set: libm:ascii:udp 0.200000 0.290000 0.490000 ( 1.129215)
|
22
|
+
set: libm:bin 0.200000 0.490000 0.690000 ( 1.929198)
|
23
|
+
set: libm:bin:buffer 0.070000 0.170000 0.240000 ( 0.318657)
|
24
|
+
set: mclient:ascii 4.870000 0.840000 5.710000 ( 5.791865)
|
25
|
+
|
26
|
+
get: cache:dalli:bin 2.030000 0.910000 2.940000 ( 3.639529)
|
27
|
+
get: cache:libm:bin 0.810000 0.680000 1.490000 ( 2.721883)
|
28
|
+
get: dalli:bin 2.010000 0.910000 2.920000 ( 3.630398)
|
29
|
+
get: libm:ascii 0.350000 0.500000 0.850000 ( 1.977741)
|
30
|
+
get: libm:ascii:pipeline 0.360000 0.700000 1.060000 ( 2.278924)
|
31
|
+
get: libm:ascii:udp 0.280000 0.300000 0.580000 ( 1.102862)
|
32
|
+
get: libm:bin 0.260000 0.660000 0.920000 ( 1.985586)
|
33
|
+
get: libm:bin:buffer 0.300000 0.890000 1.190000 ( 2.051324)
|
34
|
+
get: mclient:ascii 5.710000 0.950000 6.660000 ( 6.724394)
|
35
|
+
|
36
|
+
delete: cache:dalli:bin 1.820000 0.890000 2.710000 ( 3.373237)
|
37
|
+
delete: cache:libm:bin 0.960000 0.590000 1.550000 ( 2.928492)
|
38
|
+
delete: dalli:bin 1.790000 0.880000 2.670000 ( 3.338832)
|
39
|
+
delete: libm:ascii 0.620000 0.580000 1.200000 ( 2.428661)
|
40
|
+
delete: libm:ascii:pipeline 0.070000 0.000000 0.070000 ( 0.077325)
|
41
|
+
delete: libm:ascii:udp 0.490000 0.360000 0.850000 ( 1.310359)
|
42
|
+
delete: libm:bin 0.590000 0.560000 1.150000 ( 2.369949)
|
43
|
+
delete: libm:bin:buffer 0.600000 0.830000 1.430000 ( 2.457385)
|
44
|
+
delete: mclient:ascii 4.700000 0.820000 5.520000 ( 5.581853)
|
45
|
+
|
46
|
+
get-missing: cache:dalli:bin 1.770000 0.880000 2.650000 ( 3.331386)
|
47
|
+
get-missing: cache:libm:bin 0.970000 0.800000 1.770000 ( 2.860777)
|
48
|
+
get-missing: dalli:bin 1.760000 0.880000 2.640000 ( 3.337003)
|
49
|
+
get-missing: libm:ascii 0.660000 0.630000 1.290000 ( 2.495618)
|
50
|
+
get-missing: libm:ascii:pipeline 0.670000 0.790000 1.460000 ( 2.523977)
|
51
|
+
get-missing: libm:ascii:udp 0.540000 0.370000 0.910000 ( 1.356731)
|
52
|
+
get-missing: libm:bin 0.630000 0.730000 1.360000 ( 2.530438)
|
53
|
+
get-missing: libm:bin:buffer 0.650000 0.860000 1.510000 ( 2.535072)
|
54
|
+
get-missing: mclient:ascii 4.840000 0.840000 5.680000 ( 5.757437)
|
55
|
+
|
56
|
+
set-large: cache:dalli:bin 2.770000 0.930000 3.700000 ( 4.579959)
|
57
|
+
set-large: cache:libm:bin 1.220000 0.600000 1.820000 ( 3.422516)
|
58
|
+
set-large: dalli:bin 2.720000 0.930000 3.650000 ( 4.510348)
|
59
|
+
set-large: libm:ascii 0.330000 0.530000 0.860000 ( 2.404037)
|
60
|
+
set-large: libm:ascii:pipeline 0.160000 0.140000 0.300000 ( 0.304724)
|
61
|
+
set-large: libm:ascii:udp 0.220000 0.330000 0.550000 ( 1.246952)
|
62
|
+
set-large: libm:bin 0.230000 0.530000 0.760000 ( 2.118547)
|
63
|
+
set-large: libm:bin:buffer 0.120000 0.250000 0.370000 ( 0.453106)
|
64
|
+
set-large: mclient:ascii 5.190000 0.860000 6.050000 ( 6.136922)
|
65
|
+
|
66
|
+
get-large: cache:dalli:bin 2.420000 1.020000 3.440000 ( 4.181324)
|
67
|
+
get-large: cache:libm:bin 3.790000 0.900000 4.690000 ( 6.141065)
|
68
|
+
get-large: dalli:bin 2.390000 1.020000 3.410000 ( 4.140461)
|
69
|
+
get-large: libm:ascii 0.390000 0.640000 1.030000 ( 2.091129)
|
70
|
+
get-large: libm:ascii:pipeline 0.400000 0.760000 1.160000 ( 2.050111)
|
71
|
+
get-large: libm:ascii:udp 0.340000 0.440000 0.780000 ( 1.300560)
|
72
|
+
get-large: libm:bin 0.330000 0.830000 1.160000 ( 2.316933)
|
73
|
+
get-large: libm:bin:buffer 0.370000 1.090000 1.460000 ( 2.420931)
|
74
|
+
get-large: mclient:ascii 6.800000 1.280000 8.080000 ( 8.175742)
|
75
|
+
|
76
|
+
hash:default 0.190000 0.000000 0.190000 ( 0.194626)
|
77
|
+
hash:md5 0.340000 0.000000 0.340000 ( 0.337795)
|
78
|
+
hash:crc 0.210000 0.000000 0.210000 ( 0.214550)
|
79
|
+
hash:fnv1_64 0.160000 0.000000 0.160000 ( 0.151460)
|
80
|
+
hash:fnv1a_64 0.130000 0.000000 0.130000 ( 0.132338)
|
81
|
+
hash:fnv1_32 0.130000 0.000000 0.130000 ( 0.131782)
|
82
|
+
hash:fnv1a_32 0.130000 0.000000 0.130000 ( 0.132192)
|
83
|
+
hash:hsieh 0.060000 0.000000 0.060000 ( 0.057399)
|
84
|
+
hash:murmur 0.090000 0.000000 0.090000 ( 0.087435)
|
85
|
+
hash:jenkins 0.100000 0.000000 0.100000 ( 0.098543)
|
86
|
+
hash:none 0.060000 0.000000 0.060000 ( 0.057412)
|
@@ -0,0 +1,89 @@
|
|
1
|
+
alzabo0:~/code/cache (master) $ ruby test/profile/benchmark.rb
|
2
|
+
Darwin alzabo0 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:32:41 PDT 2011; root:xnu-1504.15.3~1/RELEASE_X86_64 x86_64
|
3
|
+
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin10.8.0]
|
4
|
+
RUBYOPT=-ropenssl
|
5
|
+
RUBY_VERSION=ruby-1.9.3-p125
|
6
|
+
Ruby 1.9.3p125
|
7
|
+
Loaded memcached 1.4.1
|
8
|
+
Loaded memcache-client 1.8.5
|
9
|
+
Loaded cache 0.2.6
|
10
|
+
Loaded kgio 2.7.4
|
11
|
+
Loaded dalli 2.0.2
|
12
|
+
Loops is 20000
|
13
|
+
Stack depth is 0
|
14
|
+
Small value size is: 19 bytes
|
15
|
+
Large value size is: 4189 bytes
|
16
|
+
No matching processes belonging to you were found
|
17
|
+
user system total real
|
18
|
+
set: cache:dalli:bin 2.200000 0.830000 3.030000 ( 3.818512)
|
19
|
+
set: cache:libm:bin 0.630000 0.550000 1.180000 ( 2.579593)
|
20
|
+
set: dalli:bin 2.080000 0.830000 2.910000 ( 3.709548)
|
21
|
+
set: libm:ascii 0.290000 0.520000 0.810000 ( 2.175071)
|
22
|
+
set: libm:ascii:pipeline 0.100000 0.010000 0.110000 ( 0.105957)
|
23
|
+
set: libm:ascii:udp 0.200000 0.310000 0.510000 ( 1.116366)
|
24
|
+
set: libm:bin 0.190000 0.480000 0.670000 ( 1.779256)
|
25
|
+
set: libm:bin:buffer 0.080000 0.160000 0.240000 ( 0.313709)
|
26
|
+
set: mclient:ascii 4.310000 0.830000 5.140000 ( 5.211834)
|
27
|
+
|
28
|
+
get: cache:dalli:bin 2.070000 0.900000 2.970000 ( 3.678416)
|
29
|
+
get: cache:libm:bin 0.580000 0.680000 1.260000 ( 2.372081)
|
30
|
+
get: dalli:bin 1.940000 0.900000 2.840000 ( 3.548862)
|
31
|
+
get: libm:ascii 0.340000 0.490000 0.830000 ( 1.850806)
|
32
|
+
get: libm:ascii:pipeline 0.350000 0.680000 1.030000 ( 2.187457)
|
33
|
+
get: libm:ascii:udp 0.260000 0.330000 0.590000 ( 1.062001)
|
34
|
+
get: libm:bin 0.260000 0.670000 0.930000 ( 1.963878)
|
35
|
+
get: libm:bin:buffer 0.300000 0.930000 1.230000 ( 2.021582)
|
36
|
+
get: mclient:ascii 5.120000 0.850000 5.970000 ( 6.057993)
|
37
|
+
|
38
|
+
delete: cache:dalli:bin 1.900000 0.880000 2.780000 ( 3.450546)
|
39
|
+
delete: cache:libm:bin 0.720000 0.670000 1.390000 ( 2.628000)
|
40
|
+
delete: dalli:bin 1.730000 0.870000 2.600000 ( 3.278894)
|
41
|
+
delete: libm:ascii 0.610000 0.580000 1.190000 ( 2.382143)
|
42
|
+
delete: libm:ascii:pipeline 0.070000 0.000000 0.070000 ( 0.077245)
|
43
|
+
delete: libm:ascii:udp 0.500000 0.380000 0.880000 ( 1.311811)
|
44
|
+
delete: libm:bin 0.590000 0.570000 1.160000 ( 2.325502)
|
45
|
+
delete: libm:bin:buffer 0.580000 0.810000 1.390000 ( 2.347620)
|
46
|
+
delete: mclient:ascii 4.150000 0.810000 4.960000 ( 5.022691)
|
47
|
+
|
48
|
+
get-missing: cache:dalli:bin 1.830000 0.870000 2.700000 ( 3.410744)
|
49
|
+
get-missing: cache:libm:bin 0.730000 0.730000 1.460000 ( 2.553246)
|
50
|
+
get-missing: dalli:bin 1.710000 0.870000 2.580000 ( 3.294497)
|
51
|
+
get-missing: libm:ascii 0.670000 0.650000 1.320000 ( 2.522556)
|
52
|
+
get-missing: libm:ascii:pipeline 0.650000 0.780000 1.430000 ( 2.408539)
|
53
|
+
get-missing: libm:ascii:udp 0.530000 0.390000 0.920000 ( 1.347747)
|
54
|
+
get-missing: libm:bin 0.640000 0.730000 1.370000 ( 2.514046)
|
55
|
+
get-missing: libm:bin:buffer 0.650000 0.880000 1.530000 ( 2.530509)
|
56
|
+
get-missing: mclient:ascii 4.230000 0.820000 5.050000 ( 5.119931)
|
57
|
+
|
58
|
+
set-large: cache:dalli:bin 2.560000 0.880000 3.440000 ( 4.314613)
|
59
|
+
set-large: cache:libm:bin 0.900000 0.650000 1.550000 ( 3.082473)
|
60
|
+
set-large: dalli:bin 2.450000 0.870000 3.320000 ( 4.192634)
|
61
|
+
set-large: libm:ascii 0.320000 0.520000 0.840000 ( 2.383214)
|
62
|
+
set-large: libm:ascii:pipeline 0.160000 0.150000 0.310000 ( 0.313549)
|
63
|
+
set-large: libm:ascii:udp 0.230000 0.360000 0.590000 ( 1.254392)
|
64
|
+
set-large: libm:bin 0.230000 0.520000 0.750000 ( 2.106144)
|
65
|
+
set-large: libm:bin:buffer 0.130000 0.250000 0.380000 ( 0.448009)
|
66
|
+
set-large: mclient:ascii 4.540000 0.860000 5.400000 ( 5.492006)
|
67
|
+
|
68
|
+
get-large: cache:dalli:bin 2.320000 0.980000 3.300000 ( 4.028261)
|
69
|
+
get-large: cache:libm:bin 3.480000 0.850000 4.330000 ( 5.709700)
|
70
|
+
get-large: dalli:bin 2.200000 0.980000 3.180000 ( 3.916877)
|
71
|
+
get-large: libm:ascii 0.380000 0.640000 1.020000 ( 2.054989)
|
72
|
+
get-large: libm:ascii:pipeline 0.380000 0.760000 1.140000 ( 1.999273)
|
73
|
+
get-large: libm:ascii:udp 0.330000 0.460000 0.790000 ( 1.286472)
|
74
|
+
get-large: libm:bin 0.330000 0.860000 1.190000 ( 2.282758)
|
75
|
+
get-large: libm:bin:buffer 0.360000 1.090000 1.450000 ( 2.388201)
|
76
|
+
get-large: mclient:ascii 5.870000 1.070000 6.940000 ( 7.044938)
|
77
|
+
|
78
|
+
hash:default 0.190000 0.000000 0.190000 ( 0.198824)
|
79
|
+
hash:md5 0.370000 0.000000 0.370000 ( 0.361487)
|
80
|
+
hash:crc 0.210000 0.000000 0.210000 ( 0.219091)
|
81
|
+
hash:fnv1_64 0.150000 0.000000 0.150000 ( 0.155696)
|
82
|
+
hash:fnv1a_64 0.140000 0.000000 0.140000 ( 0.135878)
|
83
|
+
hash:fnv1_32 0.140000 0.000000 0.140000 ( 0.138691)
|
84
|
+
hash:fnv1a_32 0.130000 0.000000 0.130000 ( 0.136036)
|
85
|
+
hash:hsieh 0.060000 0.000000 0.060000 ( 0.059796)
|
86
|
+
hash:murmur 0.090000 0.000000 0.090000 ( 0.088340)
|
87
|
+
hash:jenkins 0.100000 0.000000 0.100000 ( 0.102807)
|
88
|
+
hash:none 0.050000 0.000000 0.050000 ( 0.059193)
|
89
|
+
alzabo0:~/code/cache (master) $
|