dalli 2.7.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 4e1d2bd1cdadde91a31a3e1311e4189e54b57623
4
- data.tar.gz: 6e2fbab2dd27e1cf5f62eef39d7292d1ac6f93b8
2
+ SHA256:
3
+ metadata.gz: 4bc4fe873fe9319c9297219b7908d576470551d0e011d1299e54ebc162256a68
4
+ data.tar.gz: b60393783d05152ad67aa12298f6867127f973fbf07cd2d0dc90ab96b1d7971f
5
5
  SHA512:
6
- metadata.gz: ad6caea0b89835f15f7ddc4fd4ecab66eaa87ed969020c41fae9324da520b3e9f3b15afe53d1b14e515eafcb29cbc76c62267ce12a8c708f525ab2863e62f682
7
- data.tar.gz: 8646c41bab51faa972bd16c5e06157c1c201a862f911f3f961b252ce9fd96c1b583345068090b2606f1a302f5d106df072eb7a91acb2ecb1c73464b3ca2f6f58
6
+ metadata.gz: 1348b528243f253c111ad74e17a0ba20d8d14eb29d4f41e15f60bb2c87505c6d09404217c868f1623bd68f1ad70a644efd09fd1acca0ba2a1d0b6395387967ae
7
+ data.tar.gz: 108c5477c6399ef838a8df14e4878509ec5f7c22c33d012c19a9deb635901e9251a52c392c080fd6eb65dfb54e8084ee70cf6668a6914fd1336120aabb19b4f9
data/Gemfile CHANGED
@@ -2,11 +2,14 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'rake'
6
- gem 'kgio', :platform => :mri
7
5
  gem 'appraisal'
8
- gem 'connection_pool'
6
+ gem 'kgio', :platform => :mri
7
+ gem 'rails'
9
8
 
10
9
  group :test do
10
+ gem 'minitest'
11
+ gem 'mocha'
12
+ gem 'rake'
13
+ gem 'connection_pool'
11
14
  gem 'simplecov'
12
15
  end
data/History.md CHANGED
@@ -1,9 +1,103 @@
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
+
4
96
  2.7.0
5
97
  ==========
6
98
 
99
+ - BREAKING CHANGE:
100
+ Dalli::Client#add and #replace now return a truthy value, not boolean true or false.
7
101
  - Multithreading support with dalli\_store:
8
102
  Use :pool\_size to create a pool of shared, threadsafe Dalli clients in Rails:
9
103
  ```ruby
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 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,4 +1,4 @@
1
- Dalli [![Build Status](https://secure.travis-ci.org/mperham/dalli.png)](http://travis-ci.org/mperham/dalli) [![Dependency Status](https://gemnasium.com/mperham/dalli.png)](https://gemnasium.com/mperham/dalli) [![Code Climate](https://codeclimate.com/github/mperham/dalli.png)](https://codeclimate.com/github/mperham/dalli)
1
+ Dalli [![Build Status](https://secure.travis-ci.org/petergoldstein/dalli.svg)](http://travis-ci.org/petergoldstein/dalli)
2
2
  =====
3
3
 
4
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.
@@ -9,26 +9,6 @@ The name is a variant of Salvador Dali for his famous painting [The Persistence
9
9
 
10
10
  Dalli's initial development was sponsored by [CouchBase](http://www.couchbase.com/). Many thanks to them!
11
11
 
12
-
13
- Design
14
- ------------
15
-
16
- I decided to write Dalli after maintaining memcache-client for 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. supports SASL for use in managed environments, e.g. Heroku.
29
- 4. provides proper failover with recovery and adjustable timeouts
30
-
31
-
32
12
  Supported Ruby versions and implementations
33
13
  ------------------------------------------------
34
14
 
@@ -44,7 +24,7 @@ If you have problems, please enter an issue.
44
24
  Installation and Usage
45
25
  ------------------------
46
26
 
47
- 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 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
48
28
 
49
29
  brew install memcached
50
30
 
@@ -66,11 +46,9 @@ dc.set('abc', 123)
66
46
  value = dc.get('abc')
67
47
  ```
68
48
 
69
- 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.
70
-
71
- Dalli has no runtime dependencies and never will. You can optionally install the 'kgio' gem to
72
- give Dalli a 20-30% 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.
73
50
 
51
+ Dalli has no runtime dependencies.
74
52
 
75
53
  Usage with Rails 3.x and 4.x
76
54
  ---------------------------
@@ -90,10 +68,18 @@ config.cache_store = :dalli_store
90
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.
91
69
 
92
70
  ```ruby
93
- config.cache_store = :dalli_store, 'cache-1.example.com', 'cache-2.example.com',
71
+ config.cache_store = :dalli_store, 'cache-1.example.com', 'cache-2.example.com:11211:2',
94
72
  { :namespace => NAME_OF_RAILS_APP, :expires_in => 1.day, :compress => true }
95
73
  ```
96
74
 
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` )
76
+
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:
78
+
79
+ ```ruby
80
+ config.cache_store = :dalli_store, nil, { :namespace => NAME_OF_RAILS_APP, :expires_in => 1.day, :compress => true }
81
+ ```
82
+
97
83
  To use Dalli for Rails session storage that times out after 20 minutes, in `config/initializers/session_store.rb`:
98
84
 
99
85
  For Rails >= 3.2.4:
@@ -124,24 +110,49 @@ add :pool\_size to your `dalli_store` config:
124
110
  config.cache_store = :dalli_store, 'cache-1.example.com', { :pool_size => 5 }
125
111
  ```
126
112
 
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:
114
+
115
+ ```ruby
116
+ Rails.cache.fetch('foo', :expires_in => 300) do
117
+ 'bar'
118
+ end
119
+
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
+ ```
125
+
127
126
 
128
127
  Configuration
129
128
  ------------------------
130
129
 
130
+ **servers**: An Array of "host:port:weight" where weight allows you to distribute cache unevenly.
131
+
131
132
  Dalli::Client accepts the following options. All times are in seconds.
132
133
 
133
134
  **expires_in**: Global default for key TTL. Default is 0, which means no expiry.
134
135
 
135
- **failover**: Boolean, if true Dalli will failover to another server if the main server for a key is down.
136
+ **namespace**: If specified, prepends each key with this value to provide simple namespacing. Default is nil.
136
137
 
137
- **compress**: Boolean, if true Dalli will gzip-compress values larger than 1K.
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.
138
146
 
139
147
  **compression_min_size**: Minimum value byte size for which to attempt compression. Default is 1K.
140
148
 
141
149
  **compression_max_size**: Maximum value byte size for which to attempt compression. Default is unlimited.
142
150
 
143
- **serializer**: The serializer to use for objects being stored (ex. JSON).
144
- Default is Marshal.
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`
154
+
155
+ **keepalive**: Boolean. If true, Dalli will enable keep-alive for socket connections. Default is true.
145
156
 
146
157
  **socket_timeout**: Timeout for all socket operations (connect, read, write). Default is 0.5.
147
158
 
@@ -149,24 +160,30 @@ Default is Marshal.
149
160
 
150
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.
151
162
 
152
- **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.
153
164
 
154
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.
155
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
+
156
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.
157
170
 
158
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.
159
172
 
160
- **keepalive**: Boolean. If true, Dalli will enable keep-alive for socket connections. Default is true.
173
+ **sndbuf**: In bytes, set the socket SO_SNDBUF. Defaults to operating system default.
161
174
 
162
- **compressor**: The compressor to use for objects being stored.
163
- Default is zlib, implemented under `Dalli::Compressor`.
164
- If serving compressed data using nginx's HttpMemcachedModule, set `memcached_gzip_flag 2` and use `Dalli::GzipCompressor`
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.
165
182
 
166
183
  Features and Changes
167
184
  ------------------------
168
185
 
169
- By default, Dalli is thread-safe. Disable thread-safety at your own peril.
186
+ By default, Dalli is thread-safe. Disable thread-safety at your own peril.
170
187
 
171
188
  Dalli does not need anything special in Unicorn/Passenger since 2.0.4.
172
189
  It will detect sockets shared with child processes and gracefully reopen the
@@ -179,27 +196,29 @@ Note that Dalli does not require ActiveSupport or Rails. You can safely use it
179
196
  Helping Out
180
197
  -------------
181
198
 
182
- 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.
183
200
 
184
201
  We're not accepting new compressors. They are trivial to add in an initializer. See #385 (LZ4), #406 (Snappy)
185
202
 
186
203
  Thanks
187
204
  ------------
188
205
 
189
- Eric Wong - for help using his [kgio](http://unicorn.bogomips.org/kgio/index.html) library.
206
+ Mike Perham - for originally authoring the Dalli project and serving as maintainer and primary contributor
207
+
208
+ Eric Wong - for help using his [kgio](http://bogomips.org/kgio/) library.
190
209
 
191
210
  Brian Mitchell - for his remix-stash project which was helpful when implementing and testing the binary protocol support.
192
211
 
193
212
  [CouchBase](http://couchbase.com) - for their project sponsorship
194
213
 
195
-
196
- Author
214
+ Authors
197
215
  ----------
198
216
 
199
- Mike Perham, [mikeperham.com](http://mikeperham.com), [@mperham](http://twitter.com/mperham)
217
+ * [Peter M. Goldstein](https://github.com/petergoldstein) - current maintainer
218
+ * [Mike Perham](https://github.com/mperham) and contributors
200
219
 
201
220
 
202
221
  Copyright
203
222
  -----------
204
223
 
205
- Copyright (c) Mike Perham. See LICENSE for details.
224
+ Copyright (c) Mike Perham, Peter M. Goldstein. See LICENSE for details.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'active_support/cache'
2
3
  require 'action_dispatch/middleware/session/abstract_store'
3
4
  require 'dalli'
@@ -32,7 +33,7 @@ module ActionDispatch
32
33
  private
33
34
 
34
35
  def get_session(env, sid)
35
- sid ||= generate_sid
36
+ sid = generate_sid unless sid and !sid.empty?
36
37
  begin
37
38
  session = @pool.get(sid) || {}
38
39
  rescue Dalli::DalliError => ex