dalli 2.0.2 → 2.0.3
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.
- data/History.md +7 -0
- data/README.md +13 -0
- data/lib/active_support/cache/dalli_store.rb +2 -2
- data/lib/dalli/client.rb +1 -3
- data/lib/dalli/version.rb +1 -1
- data/test/test_active_support.rb +1 -0
- data/test/test_dalli.rb +20 -10
- data/test/test_encoding.rb +3 -14
- metadata +8 -8
data/History.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
Dalli Changelog
|
2
2
|
=====================
|
3
3
|
|
4
|
+
2.0.3
|
5
|
+
=======
|
6
|
+
|
7
|
+
- Allow proper retrieval of stored `false` values [laserlemon, #197]
|
8
|
+
- Allow non-ascii and whitespace keys, only the text protocol has those restrictions [#145]
|
9
|
+
- Fix DalliStore#delete error-handling [#196]
|
10
|
+
|
4
11
|
2.0.2
|
5
12
|
=======
|
6
13
|
|
data/README.md
CHANGED
@@ -106,6 +106,19 @@ Put this at the bottom of `config/environment.rb`:
|
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
109
|
+
Usage with Unicorn
|
110
|
+
-----------------------
|
111
|
+
|
112
|
+
Modify the `after_fork` block in your unicorn config file:
|
113
|
+
|
114
|
+
after\_fork do |server, worker|
|
115
|
+
Rails.cache.reset if Rails.cache.respond_to?(:reset)
|
116
|
+
|
117
|
+
# Reset Rails's session store
|
118
|
+
# If you know a cleaner way to find the session store instance, please let me know
|
119
|
+
ObjectSpace.each_object(ActionDispatch::Session::DalliStore) { |obj| obj.reset }
|
120
|
+
end
|
121
|
+
|
109
122
|
|
110
123
|
Configuration
|
111
124
|
------------------------
|
@@ -20,7 +20,7 @@ module ActiveSupport
|
|
20
20
|
def initialize(*addresses)
|
21
21
|
addresses = addresses.flatten
|
22
22
|
options = addresses.extract_options!
|
23
|
-
options[:
|
23
|
+
options[:compress] ||= options[:compression]
|
24
24
|
addresses << 'localhost:11211' if addresses.empty?
|
25
25
|
@data = Dalli::Client.new(addresses, options)
|
26
26
|
end
|
@@ -72,7 +72,7 @@ module ActiveSupport
|
|
72
72
|
end
|
73
73
|
|
74
74
|
def delete(name, options=nil)
|
75
|
-
|
75
|
+
delete_entry(name, options)
|
76
76
|
end
|
77
77
|
|
78
78
|
# Reads multiple keys from the cache using a single call to the
|
data/lib/dalli/client.rb
CHANGED
@@ -46,7 +46,7 @@ module Dalli
|
|
46
46
|
|
47
47
|
def get(key, options=nil)
|
48
48
|
resp = perform(:get, key)
|
49
|
-
|
49
|
+
resp.nil? || resp == 'Not found' ? nil : resp
|
50
50
|
end
|
51
51
|
|
52
52
|
##
|
@@ -257,8 +257,6 @@ module Dalli
|
|
257
257
|
|
258
258
|
def validate_key(key)
|
259
259
|
raise ArgumentError, "key cannot be blank" if !key || key.length == 0
|
260
|
-
raise ArgumentError, "illegal character in key #{key}" if key.respond_to?(:ascii_only?) && !key.ascii_only?
|
261
|
-
raise ArgumentError, "illegal character in key #{key}" if key =~ /[\x00-\x20\x7F-\xFF]/
|
262
260
|
raise ArgumentError, "key too long #{key.inspect}" if key.length > 250
|
263
261
|
end
|
264
262
|
|
data/lib/dalli/version.rb
CHANGED
data/test/test_active_support.rb
CHANGED
@@ -13,6 +13,7 @@ describe 'ActiveSupport' do
|
|
13
13
|
assert_equal 1, @dalli.increment('lkjsa', 1, nil)
|
14
14
|
assert_equal 2, @dalli.increment('lkjsa', 1, nil)
|
15
15
|
assert_equal 1, @dalli.decrement('lkjsa', 1, nil)
|
16
|
+
assert_equal true, @dalli.delete('lkjsa')
|
16
17
|
end
|
17
18
|
|
18
19
|
should 'support fetch' do
|
data/test/test_dalli.rb
CHANGED
@@ -6,21 +6,25 @@ describe 'Dalli' do
|
|
6
6
|
should 'handle deprecated options' do
|
7
7
|
dc = Dalli::Client.new('foo', :compression => true)
|
8
8
|
assert dc.instance_variable_get(:@options)[:compress]
|
9
|
+
refute dc.instance_variable_get(:@options)[:compression]
|
10
|
+
end
|
11
|
+
|
12
|
+
should 'not warn about valid options' do
|
13
|
+
dc = Dalli::Client.new('foo', :compress => true)
|
14
|
+
# Rails.logger.expects :warn
|
15
|
+
assert dc.instance_variable_get(:@options)[:compress]
|
9
16
|
end
|
10
17
|
end
|
11
18
|
|
12
19
|
describe 'key validation' do
|
13
|
-
should 'not allow
|
20
|
+
should 'not allow blanks' do
|
14
21
|
dc = Dalli::Client.new
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
assert_raises ArgumentError do
|
22
|
-
dc.set "\n", 1
|
23
|
-
end
|
22
|
+
dc.set ' ', 1
|
23
|
+
assert_equal 1, dc.get(' ')
|
24
|
+
dc.set "\t", 1
|
25
|
+
assert_equal 1, dc.get("\t")
|
26
|
+
dc.set "\n", 1
|
27
|
+
assert_equal 1, dc.get("\n")
|
24
28
|
assert_raises ArgumentError do
|
25
29
|
dc.set "", 1
|
26
30
|
end
|
@@ -326,6 +330,12 @@ describe 'Dalli' do
|
|
326
330
|
resp = dc.get('456', :raw => true)
|
327
331
|
assert_equal '0xyz9', resp
|
328
332
|
|
333
|
+
resp = dc.set('456', false)
|
334
|
+
assert_equal true, resp
|
335
|
+
|
336
|
+
resp = dc.get('456')
|
337
|
+
assert_equal false, resp
|
338
|
+
|
329
339
|
resp = dc.stats
|
330
340
|
assert_equal Hash, resp.class
|
331
341
|
|
data/test/test_encoding.rb
CHANGED
@@ -8,15 +8,13 @@ describe 'Encoding' do
|
|
8
8
|
should 'support i18n content' do
|
9
9
|
memcached do |dc|
|
10
10
|
key = 'foo'
|
11
|
-
|
11
|
+
utf_key = utf8 = 'ƒ©åÍÎ'
|
12
12
|
|
13
13
|
assert dc.set(key, utf8)
|
14
14
|
assert_equal utf8, dc.get(key)
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
dc.set(bad_key, utf8)
|
19
|
-
end
|
16
|
+
dc.set(utf_key, utf8)
|
17
|
+
assert_equal utf8, dc.get(utf_key)
|
20
18
|
end
|
21
19
|
end
|
22
20
|
|
@@ -30,14 +28,5 @@ describe 'Encoding' do
|
|
30
28
|
end
|
31
29
|
end
|
32
30
|
|
33
|
-
should 'not allow non-ASCII keys' do
|
34
|
-
memcached do |dc|
|
35
|
-
key = 'fooƒ'
|
36
|
-
assert_raises ArgumentError do
|
37
|
-
dc.set(key, 'bar')
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
31
|
end
|
43
32
|
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.0.
|
4
|
+
version: 2.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-04-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mini_shoulda
|
16
|
-
requirement: &
|
16
|
+
requirement: &70360909279380 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70360909279380
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: mocha
|
27
|
-
requirement: &
|
27
|
+
requirement: &70360909278440 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70360909278440
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rails
|
38
|
-
requirement: &
|
38
|
+
requirement: &70360909277240 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '3'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70360909277240
|
47
47
|
description: High performance memcached client for Ruby
|
48
48
|
email: mperham@gmail.com
|
49
49
|
executables: []
|