dalli 2.2.1 → 2.3.0
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/Gemfile +1 -0
- data/History.md +4 -0
- data/README.md +7 -0
- data/lib/active_support/cache/dalli_store.rb +8 -4
- data/lib/dalli.rb +11 -0
- data/lib/dalli/server.rb +4 -4
- data/lib/dalli/version.rb +1 -1
- data/test/test_encoding.rb +1 -1
- data/test/test_serializer.rb +26 -0
- metadata +109 -116
data/Gemfile
CHANGED
data/History.md
CHANGED
data/README.md
CHANGED
@@ -86,8 +86,15 @@ Here's a more comprehensive example that sets a reasonable default for maximum c
|
|
86
86
|
|
87
87
|
To use Dalli for Rails session storage that times out after 20 minutes, in `config/initializers/session_store.rb`:
|
88
88
|
|
89
|
+
For Rails >= 3.2.4:
|
90
|
+
|
89
91
|
Rails.application.config.session_store ActionDispatch::Session::CacheStore, :expire_after => 20.minutes
|
90
92
|
|
93
|
+
For Rails 3.x:
|
94
|
+
|
95
|
+
require 'action_dispatch/middleware/session/dalli_store'
|
96
|
+
Rails.application.config.session_store :dalli_store, :memcache_server => ['host1', 'host2'], :namespace => 'sessions', :key => '_foundation_session', :expire_after => 20.minutes
|
97
|
+
|
91
98
|
Dalli does not support Rails 2.x.
|
92
99
|
|
93
100
|
|
@@ -186,6 +186,14 @@ module ActiveSupport
|
|
186
186
|
@data.reset
|
187
187
|
end
|
188
188
|
|
189
|
+
def logger
|
190
|
+
Dalli.logger
|
191
|
+
end
|
192
|
+
|
193
|
+
def logger=(new_logger)
|
194
|
+
Dalli.logger = new_logger
|
195
|
+
end
|
196
|
+
|
189
197
|
protected
|
190
198
|
|
191
199
|
# Read an entry from the cache.
|
@@ -264,10 +272,6 @@ module ActiveSupport
|
|
264
272
|
logger.debug("Cache #{operation}: #{key}#{options.blank? ? "" : " (#{options.inspect})"}")
|
265
273
|
end
|
266
274
|
|
267
|
-
def logger
|
268
|
-
Dalli.logger
|
269
|
-
end
|
270
|
-
|
271
275
|
end
|
272
276
|
end
|
273
277
|
end
|
data/lib/dalli.rb
CHANGED
@@ -35,6 +35,17 @@ module Dalli
|
|
35
35
|
def self.logger=(logger)
|
36
36
|
@logger = logger
|
37
37
|
end
|
38
|
+
|
39
|
+
# Default serialization to Marshal
|
40
|
+
@serializer = Marshal
|
41
|
+
|
42
|
+
def self.serializer
|
43
|
+
@serializer
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.serializer=(serializer)
|
47
|
+
@serializer = serializer
|
48
|
+
end
|
38
49
|
end
|
39
50
|
|
40
51
|
if defined?(RAILS_VERSION) && RAILS_VERSION < '3'
|
data/lib/dalli/server.rb
CHANGED
@@ -273,7 +273,7 @@ module Dalli
|
|
273
273
|
# http://www.hjp.at/zettel/m/memcached_flags.rxml
|
274
274
|
# Looks like most clients use bit 0 to indicate native language serialization
|
275
275
|
# and bit 1 to indicate gzip compression.
|
276
|
-
|
276
|
+
FLAG_SERIALIZED = 0x1
|
277
277
|
FLAG_COMPRESSED = 0x2
|
278
278
|
|
279
279
|
def serialize(key, value, options=nil)
|
@@ -281,7 +281,7 @@ module Dalli
|
|
281
281
|
value = unless options && options[:raw]
|
282
282
|
marshalled = true
|
283
283
|
begin
|
284
|
-
|
284
|
+
Dalli.serializer.dump(value)
|
285
285
|
rescue => ex
|
286
286
|
# Marshalling can throw several different types of generic Ruby exceptions.
|
287
287
|
# Convert to a specific exception so we can special case it higher up the stack.
|
@@ -300,13 +300,13 @@ module Dalli
|
|
300
300
|
raise Dalli::DalliError, "Value too large, memcached can only store #{@options[:value_max_bytes]} bytes per key [key: #{key}, size: #{value.bytesize}]" if value.bytesize > @options[:value_max_bytes]
|
301
301
|
flags = 0
|
302
302
|
flags |= FLAG_COMPRESSED if compressed
|
303
|
-
flags |=
|
303
|
+
flags |= FLAG_SERIALIZED if marshalled
|
304
304
|
[value, flags]
|
305
305
|
end
|
306
306
|
|
307
307
|
def deserialize(value, flags)
|
308
308
|
value = Zlib::Inflate.inflate(value) if (flags & FLAG_COMPRESSED) != 0
|
309
|
-
value =
|
309
|
+
value = Dalli.serializer.load(value) if (flags & FLAG_SERIALIZED) != 0
|
310
310
|
value
|
311
311
|
rescue TypeError, ArgumentError
|
312
312
|
raise DalliError, "Unable to unmarshal value: #{$!.message}"
|
data/lib/dalli/version.rb
CHANGED
data/test/test_encoding.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'helper'
|
3
|
+
require 'json'
|
4
|
+
require 'memcached_mock'
|
5
|
+
|
6
|
+
describe 'Serializer' do
|
7
|
+
|
8
|
+
should 'default to Marshal' do
|
9
|
+
assert_equal Marshal, Dalli.serializer
|
10
|
+
end
|
11
|
+
|
12
|
+
should 'support a custom serializer' do
|
13
|
+
original_serializer = Dalli.serializer
|
14
|
+
begin
|
15
|
+
Dalli.serializer = JSON
|
16
|
+
assert_equal JSON, Dalli.serializer
|
17
|
+
|
18
|
+
memcached(19127) do |dc|
|
19
|
+
assert dc.set("json_test", {"foo" => "bar"})
|
20
|
+
assert_equal({"foo" => "bar"}, dc.get("json_test"))
|
21
|
+
end
|
22
|
+
ensure
|
23
|
+
Dalli.serializer = original_serializer
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
metadata
CHANGED
@@ -1,137 +1,130 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: dalli
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.1
|
3
|
+
version: !ruby/object:Gem::Version
|
5
4
|
prerelease:
|
5
|
+
version: 2.3.0
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
8
|
-
- Mike Perham
|
7
|
+
authors:
|
8
|
+
- Mike Perham
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ~>
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '3'
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '3'
|
12
|
+
|
13
|
+
date: 2012-10-15 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: mini_shoulda
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
type: :development
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: mocha
|
28
|
+
prerelease: false
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: "0"
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id002
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: rails
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: "3"
|
46
|
+
type: :development
|
47
|
+
version_requirements: *id003
|
62
48
|
description: High performance memcached client for Ruby
|
63
49
|
email: mperham@gmail.com
|
64
50
|
executables: []
|
51
|
+
|
65
52
|
extensions: []
|
53
|
+
|
66
54
|
extra_rdoc_files: []
|
67
|
-
|
68
|
-
|
69
|
-
- lib/
|
70
|
-
- lib/
|
71
|
-
- lib/
|
72
|
-
- lib/dalli/
|
73
|
-
- lib/dalli/
|
74
|
-
- lib/dalli/
|
75
|
-
- lib/dalli/
|
76
|
-
- lib/dalli/
|
77
|
-
- lib/dalli.rb
|
78
|
-
- lib/
|
79
|
-
-
|
80
|
-
-
|
81
|
-
-
|
82
|
-
-
|
83
|
-
-
|
84
|
-
-
|
85
|
-
-
|
86
|
-
-
|
87
|
-
- test/
|
88
|
-
- test/
|
89
|
-
- test/
|
90
|
-
- test/
|
91
|
-
- test/
|
92
|
-
- test/
|
93
|
-
- test/
|
94
|
-
- test/
|
95
|
-
- test/
|
96
|
-
- test/
|
97
|
-
- test/
|
98
|
-
- test/
|
55
|
+
|
56
|
+
files:
|
57
|
+
- lib/dalli.rb
|
58
|
+
- lib/action_dispatch/middleware/session/dalli_store.rb
|
59
|
+
- lib/active_support/cache/dalli_store.rb
|
60
|
+
- lib/dalli/client.rb
|
61
|
+
- lib/dalli/options.rb
|
62
|
+
- lib/dalli/railtie.rb
|
63
|
+
- lib/dalli/ring.rb
|
64
|
+
- lib/dalli/server.rb
|
65
|
+
- lib/dalli/socket.rb
|
66
|
+
- lib/dalli/version.rb
|
67
|
+
- lib/rack/session/dalli.rb
|
68
|
+
- LICENSE
|
69
|
+
- README.md
|
70
|
+
- History.md
|
71
|
+
- Rakefile
|
72
|
+
- Gemfile
|
73
|
+
- dalli.gemspec
|
74
|
+
- Performance.md
|
75
|
+
- test/abstract_unit.rb
|
76
|
+
- test/benchmark_test.rb
|
77
|
+
- test/helper.rb
|
78
|
+
- test/memcached_mock.rb
|
79
|
+
- test/test_active_support.rb
|
80
|
+
- test/test_dalli.rb
|
81
|
+
- test/test_encoding.rb
|
82
|
+
- test/test_failover.rb
|
83
|
+
- test/test_network.rb
|
84
|
+
- test/test_rack_session.rb
|
85
|
+
- test/test_ring.rb
|
86
|
+
- test/test_sasl.rb
|
87
|
+
- test/test_serializer.rb
|
88
|
+
- test/test_session_store.rb
|
99
89
|
homepage: http://github.com/mperham/dalli
|
100
90
|
licenses: []
|
91
|
+
|
101
92
|
post_install_message:
|
102
|
-
rdoc_options:
|
103
|
-
- --charset=UTF-8
|
104
|
-
require_paths:
|
105
|
-
- lib
|
106
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
rdoc_options:
|
94
|
+
- --charset=UTF-8
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
107
98
|
none: false
|
108
|
-
requirements:
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: "0"
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
104
|
none: false
|
114
|
-
requirements:
|
115
|
-
|
116
|
-
|
117
|
-
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: "0"
|
118
109
|
requirements: []
|
110
|
+
|
119
111
|
rubyforge_project:
|
120
|
-
rubygems_version: 1.8.
|
112
|
+
rubygems_version: 1.8.15
|
121
113
|
signing_key:
|
122
114
|
specification_version: 3
|
123
115
|
summary: High performance memcached client for Ruby
|
124
|
-
test_files:
|
125
|
-
- test/abstract_unit.rb
|
126
|
-
- test/benchmark_test.rb
|
127
|
-
- test/helper.rb
|
128
|
-
- test/memcached_mock.rb
|
129
|
-
- test/test_active_support.rb
|
130
|
-
- test/test_dalli.rb
|
131
|
-
- test/test_encoding.rb
|
132
|
-
- test/test_failover.rb
|
133
|
-
- test/test_network.rb
|
134
|
-
- test/test_rack_session.rb
|
135
|
-
- test/test_ring.rb
|
136
|
-
- test/test_sasl.rb
|
137
|
-
- test/
|
116
|
+
test_files:
|
117
|
+
- test/abstract_unit.rb
|
118
|
+
- test/benchmark_test.rb
|
119
|
+
- test/helper.rb
|
120
|
+
- test/memcached_mock.rb
|
121
|
+
- test/test_active_support.rb
|
122
|
+
- test/test_dalli.rb
|
123
|
+
- test/test_encoding.rb
|
124
|
+
- test/test_failover.rb
|
125
|
+
- test/test_network.rb
|
126
|
+
- test/test_rack_session.rb
|
127
|
+
- test/test_ring.rb
|
128
|
+
- test/test_sasl.rb
|
129
|
+
- test/test_serializer.rb
|
130
|
+
- test/test_session_store.rb
|