dalli 1.1.4 → 2.7.11

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of dalli might be problematic. Click here for more details.

checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4bc4fe873fe9319c9297219b7908d576470551d0e011d1299e54ebc162256a68
4
+ data.tar.gz: b60393783d05152ad67aa12298f6867127f973fbf07cd2d0dc90ab96b1d7971f
5
+ SHA512:
6
+ metadata.gz: 1348b528243f253c111ad74e17a0ba20d8d14eb29d4f41e15f60bb2c87505c6d09404217c868f1623bd68f1ad70a644efd09fd1acca0ba2a1d0b6395387967ae
7
+ data.tar.gz: 108c5477c6399ef838a8df14e4878509ec5f7c22c33d012c19a9deb635901e9251a52c392c080fd6eb65dfb54e8084ee70cf6668a6914fd1336120aabb19b4f9
data/Gemfile CHANGED
@@ -1,11 +1,15 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'rake'
6
- gem 'em-synchrony', :platforms => :mri_19
7
- gem 'em-spec', :platforms => :mri_19
5
+ gem 'appraisal'
6
+ gem 'kgio', :platform => :mri
7
+ gem 'rails'
8
8
 
9
9
  group :test do
10
+ gem 'minitest'
11
+ gem 'mocha'
12
+ gem 'rake'
13
+ gem 'connection_pool'
10
14
  gem 'simplecov'
11
15
  end
data/History.md CHANGED
@@ -1,6 +1,272 @@
1
1
  Dalli Changelog
2
2
  =====================
3
3
 
4
+ 2.7.11
5
+ ==========
6
+ - DEPRECATION: :dalli_store will be removed in Dalli 3.0.
7
+ Use Rails' official :mem_cache_store instead.
8
+ https://guides.rubyonrails.org/caching_with_rails.html
9
+ - Add new `digest_class` option to Dalli::Client [#724]
10
+ - Don't treat NameError as a network error [#728]
11
+ - Handle nested comma separated server strings (sambostock)
12
+
13
+ 2.7.10
14
+ ==========
15
+ - Revert frozen string change (schneems)
16
+ - Advertise supports_cached_versioning? in DalliStore (schneems)
17
+ - Better detection of fork support, to allow specs to run under Truffle Ruby (deepj)
18
+ - Update logging for over max size to log as error (aeroastro)
19
+
20
+ 2.7.9
21
+ ==========
22
+ - Fix behavior for Rails 5.2+ cache_versioning (GriwMF)
23
+ - Ensure fetch provides the key to the fallback block as an argument (0exp)
24
+ - Assorted performance improvements (schneems)
25
+
26
+ 2.7.8
27
+ ==========
28
+ - Rails 5.2 compatibility (pbougie)
29
+ - Fix Session Cache compatibility (pixeltrix)
30
+
31
+ 2.7.7
32
+ ==========
33
+ - Support large cache keys on fetch multi (sobrinho)
34
+ - Not found checks no longer trigger the result's equality method (dannyfallon)
35
+ - Use SVG build badges (olleolleolle)
36
+ - Travis updates (junaruga, tiarly, petergoldstein)
37
+ - Update default down_retry_delay (jaredhales)
38
+ - Close kgio socket after IO.select timeouts
39
+ - Documentation updates (tipair)
40
+ - Instrument DalliStore errors with instrument_errors configuration option. (btatnall)
41
+
42
+ 2.7.6
43
+ ==========
44
+ - Rails 5.0.0.beta2 compatibility (yui-knk, petergoldstein)
45
+ - Add cas!, a variant of the #cas method that yields to the block whether or not the key already exist (mwpastore)
46
+ - Performance improvements (nateberkopec)
47
+ - Add Ruby 2.3.0 to support matrix (tricknotes)
48
+
49
+ 2.7.5
50
+ ==========
51
+
52
+ - Support rcvbuff and sndbuff byte configuration. (btatnall)
53
+ - Add `:cache_nils` option to support nil values in `DalliStore#fetch` and `Dalli::Client#fetch` (wjordan, #559)
54
+ - Log retryable server errors with 'warn' instead of 'info' (phrinx)
55
+ - Fix timeout issue with Dalli::Client#get_multi_yielder (dspeterson)
56
+ - Escape namespaces with special regexp characters (Steven Peckins)
57
+ - Ensure LocalCache supports the `:raw` option and Entry unwrapping (sj26)
58
+ - Ensure bad ttl values don't cause Dalli::RingError (eagletmt, petergoldstein)
59
+ - Always pass namespaced key to instrumentation API (kaorimatz)
60
+ - Replace use of deprecated TimeoutError with Timeout::Error (eagletmt)
61
+ - Clean up gemspec, and use Bundler for loading (grosser)
62
+ - Dry up local cache testing (grosser)
63
+
64
+ 2.7.4
65
+ ==========
66
+
67
+ - Restore Windows compatibility (dfens, #524)
68
+
69
+ 2.7.3
70
+ ==========
71
+
72
+ - Assorted spec improvements
73
+ - README changes to specify defaults for failover and compress options (keen99, #470)
74
+ - SASL authentication changes to deal with Unicode characters (flypiggy, #477)
75
+ - Call to_i on ttl to accomodate ActiveSupport::Duration (#494)
76
+ - Change to implicit blocks for performance (glaucocustodio, #495)
77
+ - Change to each_key for performance (jastix, #496)
78
+ - Support stats settings - (dterei, #500)
79
+ - Raise DallError if hostname canno be parsed (dannyfallon, #501)
80
+ - Fix instrumentation for falsey values (AlexRiedler, #514)
81
+ - Support UNIX socket configurations (r-stu31, #515)
82
+
83
+ 2.7.2
84
+ ==========
85
+
86
+ - The fix for #423 didn't make it into the released 2.7.1 gem somehow.
87
+
88
+ 2.7.1
89
+ ==========
90
+
91
+ - Rack session will check if servers are up on initialization (arthurnn, #423)
92
+ - Add support for IPv6 addresses in hex form, ie: "[::1]:11211" (dplummer, #428)
93
+ - Add symbol support for namespace (jingkai #431)
94
+ - Support expiration intervals longer than 30 days (leonid-shevtsov #436)
95
+
96
+ 2.7.0
97
+ ==========
98
+
99
+ - BREAKING CHANGE:
100
+ Dalli::Client#add and #replace now return a truthy value, not boolean true or false.
101
+ - Multithreading support with dalli\_store:
102
+ Use :pool\_size to create a pool of shared, threadsafe Dalli clients in Rails:
103
+ ```ruby
104
+ config.cache_store = :dalli_store, "cache-1.example.com", "cache-2.example.com", :compress => true, :pool_size => 5, :expires_in => 300
105
+ ```
106
+ This will ensure the Rails.cache singleton does not become a source of contention.
107
+ **PLEASE NOTE** Rails's :mem\_cache\_store does not support pooling as of
108
+ Rails 4.0. You must use :dalli\_store.
109
+
110
+ - Implement `version` for retrieving version of connected servers [dterei, #384]
111
+ - Implement `fetch_multi` for batched read/write [sorentwo, #380]
112
+ - Add more support for safe updates with multiple writers: [philipmw, #395]
113
+ `require 'dalli/cas/client'` augments Dalli::Client with the following methods:
114
+ * Get value with CAS: `[value, cas] = get_cas(key)`
115
+ `get_cas(key) {|value, cas| ...}`
116
+ * Get multiple values with CAS: `get_multi_cas(k1, k2, ...) {|value, metadata| cas = metadata[:cas]}`
117
+ * Set value with CAS: `new_cas = set_cas(key, value, cas, ttl, options)`
118
+ * Replace value with CAS: `replace_cas(key, new_value, cas, ttl, options)`
119
+ * Delete value with CAS: `delete_cas(key, cas)`
120
+ - Fix bug with get key with "Not found" value [uzzz, #375]
121
+
122
+ 2.6.4
123
+ =======
124
+
125
+ - Fix ADD command, aka `write(unless_exist: true)` (pitr, #365)
126
+ - Upgrade test suite from mini\_shoulda to minitest.
127
+ - Even more performance improvements for get\_multi (xaop, #331)
128
+
129
+ 2.6.3
130
+ =======
131
+
132
+ - Support specific stats by passing `:items` or `:slabs` to `stats` method [bukhamseen]
133
+ - Fix 'can't modify frozen String' errors in `ActiveSupport::Cache::DalliStore` [dblock]
134
+ - Protect against objects with custom equality checking [theron17]
135
+ - Warn if value for key is too large to store [locriani]
136
+
137
+ 2.6.2
138
+ =======
139
+
140
+ - Properly handle missing RubyInline
141
+
142
+ 2.6.1
143
+ =======
144
+
145
+ - Add optional native C binary search for ring, add:
146
+
147
+ gem 'RubyInline'
148
+
149
+ to your Gemfile to get a 10% speedup when using many servers.
150
+ You will see no improvement if you are only using one server.
151
+
152
+ - More get_multi performance optimization [xaop, #315]
153
+ - Add lambda support for cache namespaces [joshwlewis, #311]
154
+
155
+ 2.6.0
156
+ =======
157
+
158
+ - read_multi optimization, now checks local_cache [chendo, #306]
159
+ - Re-implement get_multi to be non-blocking [tmm1, #295]
160
+ - Add `dalli` accessor to dalli_store to access the underlying
161
+ Dalli::Client, for things like `get_multi`.
162
+ - Add `Dalli::GzipCompressor`, primarily for compatibility with nginx's HttpMemcachedModule using `memcached_gzip_flag`
163
+
164
+ 2.5.0
165
+ =======
166
+
167
+ - Don't escape non-ASCII keys, memcached binary protocol doesn't care. [#257]
168
+ - :dalli_store now implements LocalCache [#236]
169
+ - Removed lots of old session_store test code, tests now all run without a default memcached server [#275]
170
+ - Changed Dalli ActiveSupport adapter to always attempt instrumentation [brianmario, #284]
171
+ - Change write operations (add/set/replace) to return false when value is too large to store [brianmario, #283]
172
+ - Allowing different compressors per client [naseem]
173
+
174
+ 2.4.0
175
+ =======
176
+ - Added the ability to swap out the compressed used to [de]compress cache data [brianmario, #276]
177
+ - Fix get\_multi performance issues with lots of memcached servers [tmm1]
178
+ - Throw more specific exceptions [tmm1]
179
+ - Allowing different types of serialization per client [naseem]
180
+
181
+ 2.3.0
182
+ =======
183
+ - Added the ability to swap out the serializer used to [de]serialize cache data [brianmario, #274]
184
+
185
+ 2.2.1
186
+ =======
187
+
188
+ - Fix issues with ENV-based connections. [#266]
189
+ - Fix problem with SessionStore in Rails 4.0 [#265]
190
+
191
+ 2.2.0
192
+ =======
193
+
194
+ - Add Rack session with\_lock helper, for Rails 4.0 support [#264]
195
+ - Accept connection string in the form of a URL (e.g., memcached://user:pass@hostname:port) [glenngillen]
196
+ - Add touch operation [#228, uzzz]
197
+
198
+ 2.1.0
199
+ =======
200
+
201
+ - Add Railtie to auto-configure Dalli when included in Gemfile [#217, steveklabnik]
202
+
203
+ 2.0.5
204
+ =======
205
+
206
+ - Create proper keys for arrays of objects passed as keys [twinturbo, #211]
207
+ - Handle long key with namespace [#212]
208
+ - Add NODELAY to TCP socket options [#206]
209
+
210
+ 2.0.4
211
+ =======
212
+
213
+ - Dalli no longer needs to be reset after Unicorn/Passenger fork [#208]
214
+ - Add option to re-raise errors rescued in the session and cache stores. [pitr, #200]
215
+ - DalliStore#fetch called the block if the cached value == false [#205]
216
+ - DalliStore should have accessible options [#195]
217
+ - Add silence and mute support for DalliStore [#207]
218
+ - Tracked down and fixed socket corruption due to Timeout [#146]
219
+
220
+ 2.0.3
221
+ =======
222
+
223
+ - Allow proper retrieval of stored `false` values [laserlemon, #197]
224
+ - Allow non-ascii and whitespace keys, only the text protocol has those restrictions [#145]
225
+ - Fix DalliStore#delete error-handling [#196]
226
+
227
+ 2.0.2
228
+ =======
229
+
230
+ - Fix all dalli\_store operations to handle nil options [#190]
231
+ - Increment and decrement with :initial => nil now return nil (lawrencepit, #112)
232
+
233
+ 2.0.1
234
+ =======
235
+
236
+ - Fix nil option handling in dalli\_store#write [#188]
237
+
238
+ 2.0.0
239
+ =======
240
+
241
+ - Reimplemented the Rails' dalli\_store to remove use of
242
+ ActiveSupport::Cache::Entry which added 109 bytes overhead to every
243
+ value stored, was a performance bottleneck and duplicated a lot of
244
+ functionality already in Dalli. One benchmark went from 4.0 sec to 3.0
245
+ sec with the new dalli\_store. [#173]
246
+ - Added reset\_stats operation [#155]
247
+ - Added support for configuring keepalive on TCP connections to memcached servers (@bianster, #180)
248
+
249
+ Notes:
250
+
251
+ * data stored with dalli\_store 2.x is NOT backwards compatible with 1.x.
252
+ Upgraders are advised to namespace their keys and roll out the 2.x
253
+ upgrade slowly so keys do not clash and caches are warmed.
254
+ `config.cache_store = :dalli_store, :expires_in => 24.hours.to_i, :namespace => 'myapp2'`
255
+ * data stored with plain Dalli::Client API is unchanged.
256
+ * removed support for dalli\_store's race\_condition\_ttl option.
257
+ * removed support for em-synchrony and unix socket connection options.
258
+ * removed support for Ruby 1.8.6
259
+ * removed memcache-client compability layer and upgrade documentation.
260
+
261
+
262
+ 1.1.5
263
+ =======
264
+
265
+ - Coerce input to incr/decr to integer via #to\_i [#165]
266
+ - Convert test suite to minitest/spec (crigor, #166)
267
+ - Fix encoding issue with keys [#162]
268
+ - Fix double namespacing with Rails and dalli\_store. [#160]
269
+
4
270
  1.1.4
5
271
  =======
6
272
 
@@ -70,7 +336,7 @@ v1.1.0 was a bad release. Yanked.
70
336
  - Allow browser session cookies (blindsey)
71
337
  - Compatibility fixes (mwynholds)
72
338
  - Add backwards compatibility module for memcache-client, require 'dalli/memcache-client'. It makes
73
- Dalli more compatible with memcache-client and prints out a warning any time you do something that
339
+ Dalli more compatible with memcache-client and prints out a warning any time you do something that
74
340
  is no longer supported so you can fix your code.
75
341
 
76
342
  1.0.1
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011 Mike Perham
1
+ Copyright (c) Peter M. Goldstein, Mike Perham
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,126 +1,158 @@
1
- Dalli
2
- =========
1
+ Dalli [![Build Status](https://secure.travis-ci.org/petergoldstein/dalli.svg)](http://travis-ci.org/petergoldstein/dalli)
2
+ =====
3
3
 
4
- Dalli is a high performance pure Ruby client for accessing memcached servers. It works with memcached 1.4+ only as it uses the newer binary protocol. It should be considered a replacement for the memcache-client gem. The API tries to be mostly compatible with memcache-client with the goal being to make it a drop-in replacement for Rails.
4
+ Dalli is a high performance pure Ruby client for accessing memcached servers. It works with memcached 1.4+ only as it uses the newer binary protocol. It should be considered a replacement for the memcache-client gem.
5
5
 
6
6
  The name is a variant of Salvador Dali for his famous painting [The Persistence of Memory](http://en.wikipedia.org/wiki/The_Persistence_of_Memory).
7
7
 
8
8
  ![Persistence of Memory](http://www.virtualdali.com/assets/paintings/31PersistenceOfMemory.jpg)
9
9
 
10
- Dalli's development is sponsored by [Membase](http://www.membase.com/). Many thanks to them!
11
-
12
-
13
- Design
14
- ------------
15
-
16
- I decided to write Dalli after maintaining memcache-client for the last two years for a few specific reasons:
17
-
18
- 0. The code is mostly old and gross. The bulk of the code is a single 1000 line .rb file.
19
- 1. It has a lot of options that are infrequently used which complicate the codebase.
20
- 2. The implementation has no single point to attach monitoring hooks.
21
- 3. Uses the old text protocol, which hurts raw performance.
22
-
23
- So a few notes. Dalli:
24
-
25
- 0. uses the exact same algorithm to choose a server so existing memcached clusters with TBs of data will work identically to memcache-client.
26
- 1. is approximately 20% faster than memcache-client (which itself was heavily optimized) in Ruby 1.9.2.
27
- 2. contains explicit "chokepoint" methods which handle all requests; these can be hooked into by monitoring tools (NewRelic, Rack::Bug, etc) to track memcached usage.
28
- 3. comes with hooks to replace memcache-client in Rails.
29
- 4. supports SASL for use in managed environments, e.g. Heroku.
30
- 5. provides proper failover with recovery and adjustable timeouts
31
- 6. has a backwards-compatibility mode for people migrating from memcache-client (see Upgrade.md).
32
-
10
+ Dalli's initial development was sponsored by [CouchBase](http://www.couchbase.com/). Many thanks to them!
33
11
 
34
12
  Supported Ruby versions and implementations
35
13
  ------------------------------------------------
36
14
 
37
- Dalli is geared towards 1.9.2+ but known to work on
15
+ Dalli should work identically on:
16
+
17
+ * JRuby 1.6+
18
+ * Ruby 1.9.3+
19
+ * Rubinius 2.0
38
20
 
39
- * Ruby 1.9.2
40
- * Ruby 1.9.3
41
- * Ruby 1.8.7
42
- * Rubinius 2.0 Preview
21
+ If you have problems, please enter an issue.
43
22
 
44
23
 
45
24
  Installation and Usage
46
25
  ------------------------
47
26
 
48
- Remember, Dalli **requires** memcached 1.4+. You can check the version with `memcached -h`. Please note that memcached that Mac OS X Snow Leopard ships with is 1.2.8 and
49
- won't work. Install 1.4.x using Homebrew with
27
+ Remember, Dalli **requires** memcached 1.4+. You can check the version with `memcached -h`. Please note that the memcached version that *Mac OS X Snow Leopard* ships with is 1.2.8 and it won't work. Install memcached 1.4.x using Homebrew with
50
28
 
51
29
  brew install memcached
52
30
 
31
+ On Ubuntu you can install it by running:
53
32
 
54
- You can verify your installation using this piece of code:
33
+ apt-get install memcached
55
34
 
56
- gem install dalli
35
+ You can verify your installation using this piece of code:
57
36
 
58
- require 'dalli'
59
- dc = Dalli::Client.new('localhost:11211')
60
- dc.set('abc', 123)
61
- value = dc.get('abc')
37
+ ```bash
38
+ gem install dalli
39
+ ```
62
40
 
63
- The test suite requires memcached 1.4.3+ with SASL enabled (brew install memcached --enable-sasl ; mv /usr/bin/memcached /usr/bin/memcached.old). Currently only supports the PLAIN mechanism.
41
+ ```ruby
42
+ require 'dalli'
43
+ options = { :namespace => "app_v1", :compress => true }
44
+ dc = Dalli::Client.new('localhost:11211', options)
45
+ dc.set('abc', 123)
46
+ value = dc.get('abc')
47
+ ```
64
48
 
65
- Dalli has no runtime dependencies and never will. You can optionally install the 'kgio' gem to
66
- give Dalli a 10-20% performance boost.
49
+ The test suite requires memcached 1.4.3+ with SASL enabled (`brew install memcached --enable-sasl ; mv /usr/bin/memcached /usr/bin/memcached.old`). Currently only supports the PLAIN mechanism.
67
50
 
51
+ Dalli has no runtime dependencies.
68
52
 
69
- Usage with Rails 3.x
53
+ Usage with Rails 3.x and 4.x
70
54
  ---------------------------
71
55
 
72
56
  In your Gemfile:
73
57
 
74
- gem 'dalli'
58
+ ```ruby
59
+ gem 'dalli'
60
+ ```
75
61
 
76
62
  In `config/environments/production.rb`:
77
63
 
78
- config.cache_store = :dalli_store
64
+ ```ruby
65
+ config.cache_store = :dalli_store
66
+ ```
79
67
 
80
- A more comprehensive example (note that we are setting a reasonable default for maximum cache entry lifetime (one day), enabling compression for large values, and namespacing all entries for this rails app. Remove the namespace if you have multiple apps which share cached values):
68
+ Here's a more comprehensive example that sets a reasonable default for maximum cache entry lifetime (one day), enables compression for large values and namespaces all entries for this rails app. Remove the namespace if you have multiple apps which share cached values.
81
69
 
82
- config.cache_store = :dalli_store, 'cache-1.example.com', 'cache-2.example.com',
83
- { :namespace => NAME_OF_RAILS_APP, :expires_in => 1.day, :compression => true }
70
+ ```ruby
71
+ config.cache_store = :dalli_store, 'cache-1.example.com', 'cache-2.example.com:11211:2',
72
+ { :namespace => NAME_OF_RAILS_APP, :expires_in => 1.day, :compress => true }
73
+ ```
84
74
 
85
- To use Dalli for Rails session storage, in `config/initializers/session_store.rb`:
75
+ You can specify a port and a weight by appending to the server name. You may wish to increase the weight of a server with more memory configured. (e.g. to specify port 11211 and a weight of 2, append `:11211:2` )
86
76
 
87
- require 'action_dispatch/middleware/session/dalli_store'
88
- Rails.application.config.session_store :dalli_store, :memcache_server => ['host1', 'host2'], :namespace => 'sessions', :key => '_foundation_session', :expire_after => 30.minutes
77
+ If your servers are specified in `ENV["MEMCACHE_SERVERS"]` (e.g. on Heroku when using a third-party hosted addon), simply provide `nil` for the servers:
89
78
 
79
+ ```ruby
80
+ config.cache_store = :dalli_store, nil, { :namespace => NAME_OF_RAILS_APP, :expires_in => 1.day, :compress => true }
81
+ ```
90
82
 
91
- Usage with Rails 2.3.x
92
- ----------------------------
83
+ To use Dalli for Rails session storage that times out after 20 minutes, in `config/initializers/session_store.rb`:
93
84
 
94
- Dalli v1.1+ does not support Rails 2.3. Please use an earlier version: gem install dalli -v "~> 1.0.4"
85
+ For Rails >= 3.2.4:
95
86
 
87
+ ```ruby
88
+ Rails.application.config.session_store ActionDispatch::Session::CacheStore, :expire_after => 20.minutes
89
+ ```
96
90
 
97
- Usage with Passenger
98
- ------------------------
91
+ For Rails 3.x:
92
+
93
+ ```ruby
94
+ require 'action_dispatch/middleware/session/dalli_store'
95
+ Rails.application.config.session_store :dalli_store, :memcache_server => ['host1', 'host2'], :namespace => 'sessions', :key => '_foundation_session', :expire_after => 20.minutes
96
+ ```
97
+
98
+ Dalli does not support Rails 2.x.
99
+
100
+
101
+ Multithreading and Rails
102
+ --------------------------
103
+
104
+ If you use Puma or another threaded app server, as of Dalli 2.7, you can use a pool
105
+ of Dalli clients with Rails to ensure the `Rails.cache` singleton does not become a
106
+ source of thread contention. You must add `gem 'connection_pool'` to your Gemfile and
107
+ add :pool\_size to your `dalli_store` config:
108
+
109
+ ```ruby
110
+ config.cache_store = :dalli_store, 'cache-1.example.com', { :pool_size => 5 }
111
+ ```
99
112
 
100
- Put this at the bottom of `config/environment.rb`:
113
+ You can then use the Rails cache as normal and Rails.cache will use the pool transparently under the covers, or you can check out a Dalli client directly from the pool:
101
114
 
102
- if defined?(PhusionPassenger)
103
- PhusionPassenger.on_event(:starting_worker_process) do |forked|
104
- # Reset Rails's object cache
105
- # Only works with DalliStore
106
- Rails.cache.reset if forked
115
+ ```ruby
116
+ Rails.cache.fetch('foo', :expires_in => 300) do
117
+ 'bar'
118
+ end
107
119
 
108
- # Reset Rails's session store
109
- # If you know a cleaner way to find the session store instance, please let me know
110
- ObjectSpace.each_object(ActionDispatch::Session::DalliStore) { |obj| obj.reset }
111
- end
112
- end
120
+ Rails.cache.dalli.with do |client|
121
+ # client is a Dalli::Client instance which you can
122
+ # use ONLY within this block
123
+ end
124
+ ```
113
125
 
114
126
 
115
127
  Configuration
116
128
  ------------------------
129
+
130
+ **servers**: An Array of "host:port:weight" where weight allows you to distribute cache unevenly.
131
+
117
132
  Dalli::Client accepts the following options. All times are in seconds.
118
133
 
119
- **expires_in**: Global default for key TTL. No default.
134
+ **expires_in**: Global default for key TTL. Default is 0, which means no expiry.
135
+
136
+ **namespace**: If specified, prepends each key with this value to provide simple namespacing. Default is nil.
137
+
138
+ **failover**: Boolean, if true Dalli will failover to another server if the main server for a key is down. Default is true.
139
+
140
+ **threadsafe**: Boolean. If true Dalli ensures that only one thread is using a socket at a given time. Default is true. You can set to false if you are using the Client within a thread-safe connection pool.
141
+
142
+ **serializer**: The serializer to use for objects being stored (ex. JSON).
143
+ Default is Marshal.
144
+
145
+ **compress**: Boolean, if true Dalli will gzip-compress values larger than 1K. Default is false.
146
+
147
+ **compression_min_size**: Minimum value byte size for which to attempt compression. Default is 1K.
148
+
149
+ **compression_max_size**: Maximum value byte size for which to attempt compression. Default is unlimited.
120
150
 
121
- **failover**: Boolean, if true Dalli will failover to another server if the main server for a key is down.
151
+ **compressor**: The compressor to use for objects being stored.
152
+ Default is zlib, implemented under `Dalli::Compressor`.
153
+ If serving compressed data using nginx's HttpMemcachedModule, set `memcached_gzip_flag 2` and use `Dalli::GzipCompressor`
122
154
 
123
- **compression**: Boolean, if true Dalli will gzip-compress values larger than 1K.
155
+ **keepalive**: Boolean. If true, Dalli will enable keep-alive for socket connections. Default is true.
124
156
 
125
157
  **socket_timeout**: Timeout for all socket operations (connect, read, write). Default is 0.5.
126
158
 
@@ -128,53 +160,65 @@ Dalli::Client accepts the following options. All times are in seconds.
128
160
 
129
161
  **socket_failure_delay**: Before retrying a socket operation, the process sleeps for this amount of time. Default is 0.01. Set to nil for no delay.
130
162
 
131
- **down_retry_delay**: When a server has been marked down due to many failures, the server will be checked again for being alive only after this amount of time. Don't set this value to low, otherwise each request which tries the failed server might hang for the maximum **socket_timeout**. Default is 1 second.
163
+ **down_retry_delay**: When a server has been marked down due to many failures, the server will be checked again for being alive only after this amount of time. Don't set this value too low, otherwise each request which tries the failed server might hang for the maximum **socket_timeout**. Default is 60 seconds.
132
164
 
133
165
  **value_max_bytes**: The maximum size of a value in memcached. Defaults to 1MB, this can be increased with memcached's -I parameter. You must also configure Dalli to allow the larger size here.
134
166
 
167
+ **error_when_over_max_size**: Boolean. If true, Dalli will throw a Dalli::ValueOverMaxSize exception when trying to store data larger than **value_max_bytes**. Defaults to false, meaning only a warning is logged.
168
+
135
169
  **username**: The username to use for authenticating this client instance against a SASL-enabled memcached server. Heroku users should not need to use this normally.
136
170
 
137
171
  **password**: The password to use for authenticating this client instance against a SASL-enabled memcached server. Heroku users should not need to use this normally.
138
172
 
139
- **async**: Boolean, if true Dalli will assume its running inside the EventMachine reactor and use EM through the em-synchrony gem. Currently disables the socket_timeout option. Default is false.
173
+ **sndbuf**: In bytes, set the socket SO_SNDBUF. Defaults to operating system default.
174
+
175
+ **rcvbuf**: In bytes, set the socket SO_RCVBUF. Defaults to operating system default.
176
+
177
+ **cache_nils**: Boolean. If true Dalli will not treat cached `nil` values as 'not found' for `#fetch` operations. Default is false.
178
+
179
+ **raise_errors**: Boolean. When true DalliStore will reraise Dalli:DalliError instead swallowing the error. Default is false.
180
+
181
+ **instrument_errors**: Boolean. When true DalliStore will send notification of Dalli::DalliError via a 'cache_error.active_support' event. Default is false.
140
182
 
141
183
  Features and Changes
142
184
  ------------------------
143
185
 
144
- Dalli is **NOT** 100% API compatible with memcache-client. If you have code which uses the MemCache API directly, it will likely need small tweaks. Method parameters and return values changed slightly. See Upgrade.md for more detail.
186
+ By default, Dalli is thread-safe. Disable thread-safety at your own peril.
145
187
 
146
- By default, Dalli is thread-safe. Disable thread-safety at your own peril.
147
-
148
- Multi-threaded use will fail if used with EventMachine.
188
+ Dalli does not need anything special in Unicorn/Passenger since 2.0.4.
189
+ It will detect sockets shared with child processes and gracefully reopen the
190
+ socket.
149
191
 
150
192
  Note that Dalli does not require ActiveSupport or Rails. You can safely use it in your own Ruby projects.
151
193
 
194
+ [View the Client API](http://www.rubydoc.info/github/mperham/dalli/Dalli/Client)
152
195
 
153
196
  Helping Out
154
197
  -------------
155
198
 
156
- If you have a fix you wish to provide, please fork the code, fix in your local project and then send a pull request on github. Please ensure that you include a test which verifies your fix and update History.md with a one sentence description of your fix so you get credit as a contributor.
199
+ If you have a fix you wish to provide, please fork the code, fix in your local project and then send a pull request on github. Please ensure that you include a test which verifies your fix and update `History.md` with a one sentence description of your fix so you get credit as a contributor.
157
200
 
201
+ We're not accepting new compressors. They are trivial to add in an initializer. See #385 (LZ4), #406 (Snappy)
158
202
 
159
203
  Thanks
160
204
  ------------
161
205
 
162
- Eric Wong - for help using his [kgio](http://unicorn.bogomips.org/kgio/index.html) library.
163
-
164
- Brian Mitchell - for his remix-stash project which was helpful when implementing and testing the binary protocol support.
206
+ Mike Perham - for originally authoring the Dalli project and serving as maintainer and primary contributor
165
207
 
166
- [Membase](http://membase.com) - for their project sponsorship
208
+ Eric Wong - for help using his [kgio](http://bogomips.org/kgio/) library.
167
209
 
168
- [Bootspring](http://bootspring.com) is my Ruby and Rails consulting company. We specialize in Ruby infrastructure, performance and scalability tuning for Rails applications. If you need help, please [contact us](mailto:info@bootspring.com) today.
210
+ Brian Mitchell - for his remix-stash project which was helpful when implementing and testing the binary protocol support.
169
211
 
212
+ [CouchBase](http://couchbase.com) - for their project sponsorship
170
213
 
171
- Author
214
+ Authors
172
215
  ----------
173
216
 
174
- Mike Perham, mperham@gmail.com, [mikeperham.com](http://mikeperham.com), [@mperham](http://twitter.com/mperham) If you like and use this project, please give me a recommendation at [WWR](http://workingwithrails.com/person/10797-mike-perham). Happy caching!
217
+ * [Peter M. Goldstein](https://github.com/petergoldstein) - current maintainer
218
+ * [Mike Perham](https://github.com/mperham) and contributors
175
219
 
176
220
 
177
221
  Copyright
178
222
  -----------
179
223
 
180
- Copyright (c) 2010 Mike Perham. See LICENSE for details.
224
+ Copyright (c) Mike Perham, Peter M. Goldstein. See LICENSE for details.