dalli 2.7.5 → 2.7.6

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
  SHA1:
3
- metadata.gz: 29b86664473df52d0ca07fbf21015a39260962a1
4
- data.tar.gz: 5061af271bef6e1db864d5e6de4f9464412e0c67
3
+ metadata.gz: aa780eecd8063c6371f755a081c672bee694c596
4
+ data.tar.gz: f044315c06b99f3ff10da4c4a37a4b77cce359da
5
5
  SHA512:
6
- metadata.gz: 7ccec720347f06a142f74d1a500948390f0dcd3520c73922363267c393d99067cb3682f4c2577cc2cbbd99a18a93f800041eaec7570303c73d5e7ab451b9396e
7
- data.tar.gz: a68483e89e28c82d52852d73c921aa40578abad55a2f3ec9106b01f1fd5dfc6f98104e9b2f8ab0006306685a4b3ecafca3d768ebf81223c213171482ee00d1f1
6
+ metadata.gz: 962196b3d7c2a75b928f32e896106ead0316b6d2614f1176041a3751c82816e5669a70d9d293ef1762df190bade229955b20c5673562600575774b3bfed6c978
7
+ data.tar.gz: c890f77ce55953a3f0fe47629ddb1eda40ece7b58628c7168e45c3733c5120e72c7dba992f6b15267ea5025283bf8f5c2e213648c65e6a87131219bfe318f5a1
data/History.md CHANGED
@@ -1,6 +1,13 @@
1
1
  Dalli Changelog
2
2
  =====================
3
3
 
4
+ 2.7.6
5
+ ==========
6
+ - Rails 5.0.0.beta2 compatibility (yui-knk, petergoldstein)
7
+ - Add cas!, a variant of the #cas method that yields to the block whether or not the key already exist (mwpastore)
8
+ - Performance improvements (nateberkopec)
9
+ - Add Ruby 2.3.0 to support matrix (tricknotes)
10
+
4
11
  2.7.5
5
12
  ==========
6
13
 
@@ -336,6 +336,7 @@ module ActiveSupport
336
336
  key = "#{prefix}:#{key}" if prefix
337
337
  key
338
338
  end
339
+ alias :normalize_key :namespaced_key
339
340
 
340
341
  # Expand key to be a consistent string value. Invoke +cache_key+ if
341
342
  # object responds to +cache_key+. Otherwise, to_param method will be
@@ -107,13 +107,19 @@ module Dalli
107
107
  # - nil if the key did not exist.
108
108
  # - false if the value was changed by someone else.
109
109
  # - true if the value was successfully updated.
110
- def cas(key, ttl=nil, options=nil)
111
- (value, cas) = perform(:cas, key)
112
- value = (!value || value == 'Not found') ? nil : value
113
- if value
114
- newvalue = yield(value)
115
- perform(:set, key, newvalue, ttl_or_default(ttl), cas, options)
116
- end
110
+ def cas(key, ttl=nil, options=nil, &block)
111
+ cas_core(key, false, ttl, options, &block)
112
+ end
113
+
114
+ ##
115
+ # like #cas, but will yield to the block whether or not the value
116
+ # already exists.
117
+ #
118
+ # Returns:
119
+ # - false if the value was changed by someone else.
120
+ # - true if the value was successfully updated.
121
+ def cas!(key, ttl=nil, options=nil, &block)
122
+ cas_core(key, true, ttl, options, &block)
117
123
  end
118
124
 
119
125
  def set(key, value, ttl=nil, options=nil)
@@ -258,6 +264,14 @@ module Dalli
258
264
 
259
265
  private
260
266
 
267
+ def cas_core(key, always_set, ttl=nil, options=nil)
268
+ (value, cas) = perform(:cas, key)
269
+ value = (!value || value == 'Not found') ? nil : value
270
+ return if value.nil? && !always_set
271
+ newvalue = yield(value)
272
+ perform(:set, key, newvalue, ttl_or_default(ttl), cas, options)
273
+ end
274
+
261
275
  def ttl_or_default(ttl)
262
276
  (ttl || @options[:expires_in]).to_i
263
277
  rescue NoMethodError
@@ -337,8 +351,8 @@ module Dalli
337
351
  end
338
352
 
339
353
  # Chokepoint method for instrumentation
340
- def perform(*all_args, &blk)
341
- return blk.call if blk
354
+ def perform(*all_args)
355
+ return yield if block_given?
342
356
  op, key, *args = *all_args
343
357
 
344
358
  key = key.to_s
@@ -408,7 +422,7 @@ module Dalli
408
422
  servers = perform_multi_response_start(servers)
409
423
 
410
424
  start = Time.now
411
- loop do
425
+ while true
412
426
  # remove any dead servers
413
427
  servers.delete_if { |s| s.sock.nil? }
414
428
  break if servers.empty?
@@ -46,11 +46,11 @@ module Dalli
46
46
  end
47
47
 
48
48
  def lock
49
- @servers.each { |s| s.lock! }
49
+ @servers.each(&:lock!)
50
50
  begin
51
51
  return yield
52
52
  ensure
53
- @servers.each { |s| s.unlock! }
53
+ @servers.each(&:unlock!)
54
54
  end
55
55
  end
56
56
 
@@ -528,7 +528,7 @@ module Dalli
528
528
 
529
529
  def keyvalue_response
530
530
  hash = {}
531
- loop do
531
+ while true
532
532
  (key_length, _, body_length, _) = read_header.unpack(KV_HEADER)
533
533
  return hash if key_length == 0
534
534
  key = read(key_length)
@@ -539,7 +539,7 @@ module Dalli
539
539
 
540
540
  def multi_response
541
541
  hash = {}
542
- loop do
542
+ while true
543
543
  (key_length, _, body_length, _) = read_header.unpack(KV_HEADER)
544
544
  return hash if key_length == 0
545
545
  flags = read(4).unpack('N')[0]
@@ -603,6 +603,8 @@ module Dalli
603
603
  REQUEST = 0x80
604
604
  RESPONSE = 0x81
605
605
 
606
+ # Response codes taken from:
607
+ # https://code.google.com/p/memcached/wiki/BinaryProtocolRevamped#Response_Status
606
608
  RESPONSE_CODES = {
607
609
  0 => 'No error',
608
610
  1 => 'Key not found',
@@ -611,9 +613,16 @@ module Dalli
611
613
  4 => 'Invalid arguments',
612
614
  5 => 'Item not stored',
613
615
  6 => 'Incr/decr on a non-numeric value',
616
+ 7 => 'The vbucket belongs to another server',
617
+ 8 => 'Authentication error',
618
+ 9 => 'Authentication continue',
614
619
  0x20 => 'Authentication required',
615
620
  0x81 => 'Unknown command',
616
621
  0x82 => 'Out of memory',
622
+ 0x83 => 'Not supported',
623
+ 0x84 => 'Internal error',
624
+ 0x85 => 'Busy',
625
+ 0x86 => 'Temporary failure'
617
626
  }
618
627
 
619
628
  OPCODES = {
@@ -28,7 +28,7 @@ begin
28
28
 
29
29
  def readfull(count)
30
30
  value = ''
31
- loop do
31
+ while true
32
32
  value << kgio_read!(count - value.bytesize)
33
33
  break if value.bytesize == count
34
34
  end
@@ -37,7 +37,7 @@ begin
37
37
 
38
38
  def read_available
39
39
  value = ''
40
- loop do
40
+ while true
41
41
  ret = kgio_tryread(8196)
42
42
  case ret
43
43
  when nil
@@ -90,7 +90,7 @@ rescue LoadError
90
90
  def readfull(count)
91
91
  value = ''
92
92
  begin
93
- loop do
93
+ while true
94
94
  value << read_nonblock(count - value.bytesize)
95
95
  break if value.bytesize == count
96
96
  end
@@ -106,7 +106,7 @@ rescue LoadError
106
106
 
107
107
  def read_available
108
108
  value = ''
109
- loop do
109
+ while true
110
110
  begin
111
111
  value << read_nonblock(8196)
112
112
  rescue Errno::EAGAIN, Errno::EWOULDBLOCK
@@ -1,3 +1,3 @@
1
1
  module Dalli
2
- VERSION = '2.7.5'
2
+ VERSION = '2.7.6'
3
3
  end
@@ -3,7 +3,7 @@ require 'dalli'
3
3
 
4
4
  module Rack
5
5
  module Session
6
- class Dalli < Abstract::ID
6
+ class Dalli < defined?(Abstract::Persisted) ? Abstract::Persisted : Abstract::ID
7
7
  attr_reader :pool, :mutex
8
8
 
9
9
  DEFAULT_OPTIONS = Abstract::ID::DEFAULT_OPTIONS.merge \
@@ -19,8 +19,22 @@ module Rack
19
19
  @pool.alive!
20
20
  end
21
21
 
22
+ if defined?(Abstract::Persisted)
23
+ def find_session(req, sid)
24
+ get_session req.env, sid
25
+ end
26
+
27
+ def write_session(req, sid, session, options)
28
+ set_session req.env, sid, session, options
29
+ end
30
+
31
+ def delete_session(req, sid, options)
32
+ destroy_session req.env, sid, options
33
+ end
34
+ end
35
+
22
36
  def generate_sid
23
- loop do
37
+ while true
24
38
  sid = super
25
39
  break sid unless @pool.get(sid)
26
40
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dalli
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.5
4
+ version: 2.7.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter M. Goldstein
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-12-16 00:00:00.000000000 Z
12
+ date: 2016-02-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
@@ -169,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
169
  version: '0'
170
170
  requirements: []
171
171
  rubyforge_project:
172
- rubygems_version: 2.5.1
172
+ rubygems_version: 2.4.5.1
173
173
  signing_key:
174
174
  specification_version: 4
175
175
  summary: High performance memcached client for Ruby