memcached_store 0.12.3 → 0.12.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 49bdd6128d689edeb751f5144e0e657e52d82d67
|
|
4
|
+
data.tar.gz: 7b788ed80be35df4cd85784bf4b101f57de3e608
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dc602ee1dd34fbd99080b5f484a03d73c3a4e241c50438bdd5295fe68d0fa2ef921671a419d8be9d01fccab2f3df80df0f906e2dd0f361679014e2c873cc74ca
|
|
7
|
+
data.tar.gz: d3fd893033bb1dea5d6e72ee0754694d85918709f739fbbe7ac170fd89d5e7bd533975bf414ed8e17856d184c130bdd81fa827eed5f3dc8d1b8582479ee34542
|
data/Rakefile
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
require 'rake'
|
|
1
|
+
require 'bundler/gem_tasks'
|
|
3
2
|
require 'rake/testtask'
|
|
3
|
+
|
|
4
4
|
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
|
|
5
5
|
require "memcached_store/version"
|
|
6
6
|
|
|
7
|
-
task :default =>
|
|
7
|
+
task :default => :test
|
|
8
8
|
|
|
9
9
|
desc 'run test suite with default parser'
|
|
10
10
|
Rake::TestTask.new do |t|
|
|
@@ -14,19 +14,8 @@ Rake::TestTask.new do |t|
|
|
|
14
14
|
t.verbose = true
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
task :
|
|
18
|
-
task :build do
|
|
19
|
-
system "gem build memcached_store.gemspec"
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
task :install => :build do
|
|
23
|
-
system "gem install memcached_store-#{MemcachedStore::VERSION}.gem"
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
task :release => :build do
|
|
17
|
+
task :tag => :build do
|
|
27
18
|
system "git commit -m'Released version #{MemcachedStore::VERSION}' --allow-empty"
|
|
28
19
|
system "git tag -a v#{MemcachedStore::VERSION} -m 'Tagging #{MemcachedStore::VERSION}'"
|
|
29
20
|
system "git push --tags"
|
|
30
|
-
system "gem push memcached_store-#{MemcachedStore::VERSION}.gem"
|
|
31
|
-
system "rm memcached_store-#{MemcachedStore::VERSION}.gem"
|
|
32
21
|
end
|
|
@@ -71,7 +71,7 @@ module ActiveSupport
|
|
|
71
71
|
key = namespaced_key(name, options)
|
|
72
72
|
|
|
73
73
|
instrument(:cas, name, options) do
|
|
74
|
-
@data.cas(key, expiration(options), options
|
|
74
|
+
@data.cas(key, expiration(options), cas_raw?(options)) do |raw_value|
|
|
75
75
|
entry = deserialize_entry(raw_value)
|
|
76
76
|
value = yield entry.value
|
|
77
77
|
serialize_entry(Entry.new(value, options), options)
|
|
@@ -88,7 +88,7 @@ module ActiveSupport
|
|
|
88
88
|
keys_to_names = Hash[names.map{|name| [escape_key(namespaced_key(name, options)), name]}]
|
|
89
89
|
|
|
90
90
|
instrument(:cas_multi, names, options) do
|
|
91
|
-
@data.cas(keys_to_names.keys, expiration(options), options
|
|
91
|
+
@data.cas(keys_to_names.keys, expiration(options), cas_raw?(options)) do |raw_values|
|
|
92
92
|
values = {}
|
|
93
93
|
raw_values.each do |key, raw_value|
|
|
94
94
|
entry = deserialize_entry(raw_value)
|
|
@@ -185,6 +185,10 @@ module ActiveSupport
|
|
|
185
185
|
entry
|
|
186
186
|
end
|
|
187
187
|
|
|
188
|
+
def cas_raw?(options)
|
|
189
|
+
options[:raw]
|
|
190
|
+
end
|
|
191
|
+
|
|
188
192
|
def expiration(options)
|
|
189
193
|
expires_in = options[:expires_in].to_i
|
|
190
194
|
if expires_in > 0 && !options[:raw]
|
|
@@ -3,7 +3,7 @@ require 'test_helper'
|
|
|
3
3
|
class TestMemcachedSnappyStore < ActiveSupport::TestCase
|
|
4
4
|
|
|
5
5
|
setup do
|
|
6
|
-
@cache = ActiveSupport::Cache.lookup_store(:memcached_snappy_store)
|
|
6
|
+
@cache = ActiveSupport::Cache.lookup_store(:memcached_snappy_store, support_cas: true)
|
|
7
7
|
@cache.clear
|
|
8
8
|
end
|
|
9
9
|
|
|
@@ -98,4 +98,67 @@ class TestMemcachedSnappyStore < ActiveSupport::TestCase
|
|
|
98
98
|
actual_cache_value = @cache.instance_variable_get(:@data).get(key, true)
|
|
99
99
|
assert_equal 'value', Snappy.inflate(actual_cache_value)
|
|
100
100
|
end
|
|
101
|
+
|
|
102
|
+
test "cas should use snappy to read and write cache entries" do
|
|
103
|
+
entry_value = { :omg => 'data' }
|
|
104
|
+
update_value = 'value'
|
|
105
|
+
key = 'ponies'
|
|
106
|
+
|
|
107
|
+
@cache.write(key, entry_value)
|
|
108
|
+
result = @cache.cas(key) do |v|
|
|
109
|
+
assert_equal entry_value, v
|
|
110
|
+
update_value
|
|
111
|
+
end
|
|
112
|
+
assert result
|
|
113
|
+
assert_equal update_value, @cache.read(key)
|
|
114
|
+
|
|
115
|
+
actual_cache_value = @cache.instance_variable_get(:@data).get(key, true)
|
|
116
|
+
serialized_entry = Snappy.inflate(actual_cache_value)
|
|
117
|
+
entry = Marshal.load(serialized_entry)
|
|
118
|
+
assert entry.is_a?(ActiveSupport::Cache::Entry)
|
|
119
|
+
assert_equal update_value, entry.value
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
test "cas should support raw entries that don't use marshal format" do
|
|
123
|
+
key = 'key'
|
|
124
|
+
@cache.write(key, 'value', :raw => true)
|
|
125
|
+
result = @cache.cas(key, :raw => true) do |v|
|
|
126
|
+
assert_equal 'value', v
|
|
127
|
+
'new_value'
|
|
128
|
+
end
|
|
129
|
+
assert result
|
|
130
|
+
actual_cache_value = @cache.instance_variable_get(:@data).get(key, true)
|
|
131
|
+
assert_equal 'new_value', Snappy.inflate(actual_cache_value)
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
test "cas_multi should use snappy to read and write cache entries" do
|
|
135
|
+
keys = %w{ one two three }
|
|
136
|
+
values = keys.map{ |k| k * 10 }
|
|
137
|
+
update_hash = {"two" => "two" * 11}
|
|
138
|
+
|
|
139
|
+
keys.zip(values) { |k, v| @cache.write(k, v) }
|
|
140
|
+
|
|
141
|
+
result = @cache.cas_multi(*keys) do |hash|
|
|
142
|
+
assert_equal Hash[keys.zip(values)], hash
|
|
143
|
+
update_hash
|
|
144
|
+
end
|
|
145
|
+
assert result
|
|
146
|
+
assert_equal Hash[keys.zip(values)].merge(update_hash), @cache.read_multi(*keys)
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
test "cas_multi should support raw entries that don't use marshal format" do
|
|
150
|
+
keys = %w{ one two three }
|
|
151
|
+
values = keys.map{ |k| k * 10 }
|
|
152
|
+
update_hash = {"two" => "two" * 11}
|
|
153
|
+
|
|
154
|
+
keys.zip(values) { |k, v| @cache.write(k, v) }
|
|
155
|
+
|
|
156
|
+
result = @cache.cas_multi(*keys, :raw => true) do |hash|
|
|
157
|
+
assert_equal Hash[keys.zip(values)], hash
|
|
158
|
+
update_hash
|
|
159
|
+
end
|
|
160
|
+
assert result
|
|
161
|
+
actual_cache_value = @cache.instance_variable_get(:@data).get("two", true)
|
|
162
|
+
assert_equal update_hash["two"], Snappy.inflate(actual_cache_value)
|
|
163
|
+
end
|
|
101
164
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: memcached_store
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.12.
|
|
4
|
+
version: 0.12.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Camilo Lopez
|
|
@@ -11,7 +11,7 @@ authors:
|
|
|
11
11
|
autorequire:
|
|
12
12
|
bindir: bin
|
|
13
13
|
cert_chain: []
|
|
14
|
-
date: 2014-
|
|
14
|
+
date: 2014-06-04 00:00:00.000000000 Z
|
|
15
15
|
dependencies:
|
|
16
16
|
- !ruby/object:Gem::Dependency
|
|
17
17
|
name: activesupport
|