dalli 2.7.7 → 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
2
  SHA256:
3
- metadata.gz: be20ed3535eb5ddc41d8d53e596adc7fe7e7d4241ff345e79f29fb1c6b732a01
4
- data.tar.gz: 39e7c9ea59332d26a2b8ca7276664f3028bbe0b3db3481aa24bc478b5019f3aa
3
+ metadata.gz: 4bc4fe873fe9319c9297219b7908d576470551d0e011d1299e54ebc162256a68
4
+ data.tar.gz: b60393783d05152ad67aa12298f6867127f973fbf07cd2d0dc90ab96b1d7971f
5
5
  SHA512:
6
- metadata.gz: 9ca82a471a6ae90c123c1888117e87fbc6e348a3401b3db77f5982574d5dc46e0765681df22815773c27d204fa9023841b0012db7a37ec72569eeeddc5e53a3b
7
- data.tar.gz: 93cef3703a4b7c48e1127228b11d03565feba4523dfc1057f6689f50627b1bbb29c0fcea2d703e8500bfdb5fc70da2b975736032452610550f6acf7dace76025
6
+ metadata.gz: 1348b528243f253c111ad74e17a0ba20d8d14eb29d4f41e15f60bb2c87505c6d09404217c868f1623bd68f1ad70a644efd09fd1acca0ba2a1d0b6395387967ae
7
+ data.tar.gz: 108c5477c6399ef838a8df14e4878509ec5f7c22c33d012c19a9deb635901e9251a52c392c080fd6eb65dfb54e8084ee70cf6668a6914fd1336120aabb19b4f9
data/Gemfile CHANGED
@@ -2,4 +2,14 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
+ gem 'appraisal'
5
6
  gem 'kgio', :platform => :mri
7
+ gem 'rails'
8
+
9
+ group :test do
10
+ gem 'minitest'
11
+ gem 'mocha'
12
+ gem 'rake'
13
+ gem 'connection_pool'
14
+ gem 'simplecov'
15
+ end
data/History.md CHANGED
@@ -1,6 +1,42 @@
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)
4
40
  - Instrument DalliStore errors with instrument_errors configuration option. (btatnall)
5
41
 
6
42
  2.7.6
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- Dalli [![Build Status](https://secure.travis-ci.org/petergoldstein/dalli.svg)](http://travis-ci.org/petergoldstein/dalli) [![Dependency Status](https://gemnasium.com/petergoldstein/dalli.svg)](https://gemnasium.com/petergoldstein/dalli) [![Code Climate](https://codeclimate.com/github/petergoldstein/dalli.svg)](https://codeclimate.com/github/petergoldstein/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
- Mike Perham 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
 
@@ -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
  ---------------------------
@@ -159,7 +137,7 @@ Dalli::Client accepts the following options. All times are in seconds.
159
137
 
160
138
  **failover**: Boolean, if true Dalli will failover to another server if the main server for a key is down. Default is true.
161
139
 
162
- **threadsafe**: Boolean. If true Dalli ensures that only one thread is using a socket at a given time. Default is true. Set to false at your own peril.
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.
163
141
 
164
142
  **serializer**: The serializer to use for objects being stored (ex. JSON).
165
143
  Default is Marshal.
@@ -205,7 +183,7 @@ If serving compressed data using nginx's HttpMemcachedModule, set `memcached_gzi
205
183
  Features and Changes
206
184
  ------------------------
207
185
 
208
- 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.
209
187
 
210
188
  Dalli does not need anything special in Unicorn/Passenger since 2.0.4.
211
189
  It will detect sockets shared with child processes and gracefully reopen the
@@ -218,7 +196,7 @@ Note that Dalli does not require ActiveSupport or Rails. You can safely use it
218
196
  Helping Out
219
197
  -------------
220
198
 
221
- 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.
222
200
 
223
201
  We're not accepting new compressors. They are trivial to add in an initializer. See #385 (LZ4), #406 (Snappy)
224
202
 
@@ -9,6 +9,10 @@ module ActiveSupport
9
9
  attr_reader :silence, :options
10
10
  alias_method :silence?, :silence
11
11
 
12
+ def self.supports_cache_versioning?
13
+ true
14
+ end
15
+
12
16
  # Silence the logger.
13
17
  def silence!
14
18
  @silence = true
@@ -46,6 +50,11 @@ module ActiveSupport
46
50
  # wish to use pool support.
47
51
  #
48
52
  def initialize(*addresses)
53
+ puts <<-EOS
54
+ DEPRECATION: :dalli_store will be removed in Dalli 3.0.
55
+ Please use Rails' official :mem_cache_store instead.
56
+ https://guides.rubyonrails.org/caching_with_rails.html
57
+ EOS
49
58
  addresses = addresses.flatten
50
59
  options = addresses.extract_options!
51
60
  @options = options.dup
@@ -111,7 +120,7 @@ module ActiveSupport
111
120
 
112
121
  if not_found == entry
113
122
  result = instrument_with_log(:generate, namespaced_name, options) do |payload|
114
- yield
123
+ yield(name)
115
124
  end
116
125
  write(name, result, options)
117
126
  result
@@ -337,19 +346,22 @@ module ActiveSupport
337
346
  private
338
347
 
339
348
  def namespaced_key(key, options)
349
+ digest_class = @options[:digest_class] || ::Digest::MD5
340
350
  key = expanded_key(key)
341
351
  namespace = options[:namespace] if options
342
352
  prefix = namespace.is_a?(Proc) ? namespace.call : namespace
343
353
  key = "#{prefix}:#{key}" if prefix
344
- key = "#{key[0, 213]}:md5:#{Digest::MD5.hexdigest(key)}" if key && key.size > 250
354
+ key = "#{key[0, 213]}:md5:#{digest_class.hexdigest(key)}" if key && key.size > 250
345
355
  key
346
356
  end
347
357
  alias :normalize_key :namespaced_key
348
358
 
349
- # Expand key to be a consistent string value. Invoke +cache_key+ if
350
- # object responds to +cache_key+. Otherwise, to_param method will be
351
- # called. If the key is a Hash, then keys will be sorted alphabetically.
359
+ # Expand key to be a consistent string value. Invokes +cache_key_with_version+
360
+ # first to support Rails 5.2 cache versioning.
361
+ # Invoke +cache_key+ if object responds to +cache_key+. Otherwise, to_param method
362
+ # will be called. If the key is a Hash, then keys will be sorted alphabetically.
352
363
  def expanded_key(key) # :nodoc:
364
+ return key.cache_key_with_version.to_s if key.respond_to?(:cache_key_with_version)
353
365
  return key.cache_key.to_s if key.respond_to?(:cache_key)
354
366
 
355
367
  case key
@@ -411,7 +423,7 @@ module ActiveSupport
411
423
  module LocalCacheEntryUnwrapAndRaw # :nodoc:
412
424
  protected
413
425
  def read_entry(key, options)
414
- retval = super
426
+ retval = super(key, **options)
415
427
  if retval.is_a? ActiveSupport::Cache::Entry
416
428
  # Must have come from LocalStore, unwrap it
417
429
  if options[:raw]
data/lib/dalli.rb CHANGED
@@ -20,7 +20,7 @@ module Dalli
20
20
  # application error in marshalling deserialization or decompression
21
21
  class UnmarshalError < DalliError; end
22
22
  # payload too big for memcached
23
- class ValueOverMaxSize < RuntimeError; end
23
+ class ValueOverMaxSize < DalliError; end
24
24
 
25
25
  def self.logger
26
26
  @logger ||= (rails_logger || default_logger)
data/lib/dalli/client.rb CHANGED
@@ -29,6 +29,7 @@ module Dalli
29
29
  # - :serializer - defaults to Marshal
30
30
  # - :compressor - defaults to zlib
31
31
  # - :cache_nils - defaults to false, if true Dalli will not treat cached nil values as 'not found' for #fetch operations.
32
+ # - :digest_class - defaults to Digest::MD5, allows you to pass in an object that responds to the hexdigest method, useful for injecting a FIPS compliant hash object.
32
33
  #
33
34
  def initialize(servers=nil, options={})
34
35
  @servers = normalize_servers(servers || ENV["MEMCACHE_SERVERS"] || '127.0.0.1:11211')
@@ -64,7 +65,10 @@ module Dalli
64
65
  # If a block is given, yields key/value pairs one at a time.
65
66
  # Otherwise returns a hash of { 'key' => 'value', 'key2' => 'value1' }
66
67
  def get_multi(*keys)
67
- return {} if keys.flatten.compact.empty?
68
+ check_keys = keys.flatten
69
+ check_keys.compact!
70
+
71
+ return {} if check_keys.empty?
68
72
  if block_given?
69
73
  get_multi_yielder(keys) {|k, data| yield k, data.first}
70
74
  else
@@ -292,7 +296,9 @@ module Dalli
292
296
  end
293
297
 
294
298
  def mapped_keys(keys)
295
- keys.flatten.map {|a| validate_key(a.to_s)}
299
+ keys_array = keys.flatten
300
+ keys_array.map! { |a| validate_key(a.to_s) }
301
+ keys_array
296
302
  end
297
303
 
298
304
  def make_multi_get_requests(groups)
@@ -326,13 +332,15 @@ module Dalli
326
332
 
327
333
  ##
328
334
  # Normalizes the argument into an array of servers.
329
- # If the argument is a string, it's expected that the URIs are comma separated e.g.
335
+ # If the argument is a string, or an array containing strings, it's expected that the URIs are comma separated e.g.
330
336
  # "memcache1.example.com:11211,memcache2.example.com:11211,memcache3.example.com:11211"
331
337
  def normalize_servers(servers)
332
- if servers.is_a? String
333
- return servers.split(",")
334
- else
335
- return servers
338
+ Array(servers).flat_map do |server|
339
+ if server.is_a? String
340
+ server.split(",")
341
+ else
342
+ server
343
+ end
336
344
  end
337
345
  end
338
346
 
@@ -373,8 +381,9 @@ module Dalli
373
381
  raise ArgumentError, "key cannot be blank" if !key || key.length == 0
374
382
  key = key_with_namespace(key)
375
383
  if key.length > 250
384
+ digest_class = @options[:digest_class] || ::Digest::MD5
376
385
  max_length_before_namespace = 212 - (namespace || '').size
377
- key = "#{key[0, max_length_before_namespace]}:md5:#{Digest::MD5.hexdigest(key)}"
386
+ key = "#{key[0, max_length_before_namespace]}:md5:#{digest_class.hexdigest(key)}"
378
387
  end
379
388
  return key
380
389
  end
@@ -402,6 +411,9 @@ module Dalli
402
411
  rescue NoMethodError
403
412
  raise ArgumentError, "cannot convert :expires_in => #{opts[:expires_in].inspect} to an integer"
404
413
  end
414
+ if opts[:digest_class] && !opts[:digest_class].respond_to?(:hexdigest)
415
+ raise ArgumentError, "The digest_class object must respond to the hexdigest method"
416
+ end
405
417
  opts
406
418
  end
407
419
 
data/lib/dalli/server.rb CHANGED
@@ -447,6 +447,9 @@ module Dalli
447
447
  rescue ArgumentError
448
448
  raise if $!.message !~ /undefined class|marshal data too short/
449
449
  raise UnmarshalError, "Unable to unmarshal value: #{$!.message}"
450
+ rescue NameError
451
+ raise if $!.message !~ /uninitialized constant/
452
+ raise UnmarshalError, "Unable to unmarshal value: #{$!.message}"
450
453
  rescue Zlib::Error
451
454
  raise UnmarshalError, "Unable to uncompress value: #{$!.message}"
452
455
  end
@@ -477,7 +480,7 @@ module Dalli
477
480
  message = "Value for #{key} over max size: #{@options[:value_max_bytes]} <= #{value.bytesize}"
478
481
  raise Dalli::ValueOverMaxSize, message if @options[:error_when_over_max_size]
479
482
 
480
- Dalli.logger.warn message
483
+ Dalli.logger.error "#{message} - this value may be truncated by memcached"
481
484
  false
482
485
  end
483
486
  end
data/lib/dalli/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Dalli
3
- VERSION = '2.7.7'
3
+ VERSION = '2.7.11'
4
4
  end
@@ -157,18 +157,9 @@ module Rack
157
157
  [nil, mserv, mopts, popts]
158
158
  end
159
159
 
160
- # Capture generate_sid's super so we can call it from generate_sid_with
161
- alias_method :generate_sid_super, :generate_sid
162
-
163
- def generate_sid
164
- # no way to check env['rack.multithread'] here so fall back on
165
- # Dalli::Client or ConnectionPool's internal mutex cf. our own
166
- @pool.with {|dc| generate_sid_with(dc) }
167
- end
168
-
169
160
  def generate_sid_with(dc)
170
161
  while true
171
- sid = generate_sid_super
162
+ sid = generate_sid
172
163
  break sid unless dc.get(sid)
173
164
  end
174
165
  end
metadata CHANGED
@@ -1,128 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dalli
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.7
4
+ version: 2.7.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter M. Goldstein
8
8
  - Mike Perham
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-03-15 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: minitest
16
- requirement: !ruby/object:Gem::Requirement
17
- requirements:
18
- - - ">="
19
- - !ruby/object:Gem::Version
20
- version: 4.2.0
21
- type: :development
22
- prerelease: false
23
- version_requirements: !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- version: 4.2.0
28
- - !ruby/object:Gem::Dependency
29
- name: mocha
30
- requirement: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: '0'
35
- type: :development
36
- prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- version: '0'
42
- - !ruby/object:Gem::Dependency
43
- name: rails
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - "~>"
47
- - !ruby/object:Gem::Version
48
- version: '4'
49
- type: :development
50
- prerelease: false
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - "~>"
54
- - !ruby/object:Gem::Version
55
- version: '4'
56
- - !ruby/object:Gem::Dependency
57
- name: rake
58
- requirement: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- version: '0'
63
- type: :development
64
- prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- version: '0'
70
- - !ruby/object:Gem::Dependency
71
- name: appraisal
72
- requirement: !ruby/object:Gem::Requirement
73
- requirements:
74
- - - ">="
75
- - !ruby/object:Gem::Version
76
- version: '0'
77
- type: :development
78
- prerelease: false
79
- version_requirements: !ruby/object:Gem::Requirement
80
- requirements:
81
- - - ">="
82
- - !ruby/object:Gem::Version
83
- version: '0'
84
- - !ruby/object:Gem::Dependency
85
- name: connection_pool
86
- requirement: !ruby/object:Gem::Requirement
87
- requirements:
88
- - - ">="
89
- - !ruby/object:Gem::Version
90
- version: '0'
91
- type: :development
92
- prerelease: false
93
- version_requirements: !ruby/object:Gem::Requirement
94
- requirements:
95
- - - ">="
96
- - !ruby/object:Gem::Version
97
- version: '0'
98
- - !ruby/object:Gem::Dependency
99
- name: rdoc
100
- requirement: !ruby/object:Gem::Requirement
101
- requirements:
102
- - - ">="
103
- - !ruby/object:Gem::Version
104
- version: '0'
105
- type: :development
106
- prerelease: false
107
- version_requirements: !ruby/object:Gem::Requirement
108
- requirements:
109
- - - ">="
110
- - !ruby/object:Gem::Version
111
- version: '0'
112
- - !ruby/object:Gem::Dependency
113
- name: simplecov
114
- requirement: !ruby/object:Gem::Requirement
115
- requirements:
116
- - - ">="
117
- - !ruby/object:Gem::Version
118
- version: '0'
119
- type: :development
120
- prerelease: false
121
- version_requirements: !ruby/object:Gem::Requirement
122
- requirements:
123
- - - ">="
124
- - !ruby/object:Gem::Version
125
- version: '0'
12
+ date: 2020-09-26 00:00:00.000000000 Z
13
+ dependencies: []
126
14
  description: High performance memcached client for Ruby
127
15
  email:
128
16
  - peter.m.goldstein@gmail.com
@@ -152,9 +40,8 @@ homepage: https://github.com/petergoldstein/dalli
152
40
  licenses:
153
41
  - MIT
154
42
  metadata: {}
155
- post_install_message:
156
- rdoc_options:
157
- - "--charset=UTF-8"
43
+ post_install_message:
44
+ rdoc_options: []
158
45
  require_paths:
159
46
  - lib
160
47
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -168,9 +55,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
55
  - !ruby/object:Gem::Version
169
56
  version: '0'
170
57
  requirements: []
171
- rubyforge_project:
172
- rubygems_version: 2.7.5
173
- signing_key:
58
+ rubyforge_project:
59
+ rubygems_version: 2.7.6.2
60
+ signing_key:
174
61
  specification_version: 4
175
62
  summary: High performance memcached client for Ruby
176
63
  test_files: []