libmemcached_store 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 2d87f1bd5de0cc28f40c93a4150466fb4861d779
4
- data.tar.gz: b7270e1c498201ab93354f799b41bb2d0de560fe
2
+ SHA256:
3
+ metadata.gz: d6640a808c446950da52f6d7276241a6fa2f11e675564afbe9f2300e968e55ea
4
+ data.tar.gz: af0d711fa82540e1dded2d6ce7a3d9dbf6311a269645ffdacbd744c73c6e783b
5
5
  SHA512:
6
- metadata.gz: 25681bfd4c7fc16fbae4fd306df48597fb1f5e6c83151114e1c46579bd4b7df615f0fff346fd8a2c236fb3f30bf1767c90bbbe0777c6005903dd0f185289f42b
7
- data.tar.gz: ed9a4e4d2f3b7b8671f35e371be419c59d2ae6b5879ce377797baa0f54582ea13e48b659e69860aaad75ba7da2d85533bc4bfa2b7e189d49928fcff442014976
6
+ metadata.gz: bc2be35a5c0e401bddb5af06f6c06859734708228ba69cc1f92a1287c3de60a62e7efb3364cd4508977eaddd4a86789ef8f84c9b1b366fb92bbf0f0d9b04d193
7
+ data.tar.gz: 3a559423aff027fb95d7de114f6b56775b7386a89dc6fd807731912603f6e8b0ddd1e8fd7749892a29f27cc822da345a1ccda128dc4e9729d525acc4db2f393d
@@ -1,5 +1,5 @@
1
1
  require 'memcached'
2
- require 'memcached/get_with_flags'
2
+ require 'libmemcached_store/memcached_with_flags'
3
3
 
4
4
  require 'digest/md5'
5
5
 
@@ -23,10 +23,6 @@ module ActiveSupport
23
23
  # :client => { :no_block => true }
24
24
  #
25
25
  class LibmemcachedStore
26
- class MemcachedWithFlags < Memcached
27
- include GetWithFlags
28
- end
29
-
30
26
  class FetchWithRaceConditionTTLEntry
31
27
  attr_accessor :value, :extended
32
28
 
@@ -82,7 +78,7 @@ module ActiveSupport
82
78
 
83
79
  @options = {compress_threshold: DEFAULT_COMPRESS_THRESHOLD}.merge(options)
84
80
  @addresses = addresses
85
- @cache = MemcachedWithFlags.new(@addresses, DEFAULT_CLIENT_OPTIONS.merge(client_options))
81
+ @cache = ::LibmemcachedStore::MemcachedWithFlags.new(@addresses, DEFAULT_CLIENT_OPTIONS.merge(client_options))
86
82
  end
87
83
 
88
84
  def fetch(key, options = nil, &block)
@@ -295,7 +291,8 @@ module ActiveSupport
295
291
  value
296
292
  end
297
293
 
298
- def normalize_key(key)
294
+ # TODO: support namespace or other things passed as option
295
+ def normalize_key(key, _options = nil)
299
296
  escape_and_normalize(expanded_key(key))
300
297
  end
301
298
 
@@ -0,0 +1,47 @@
1
+ #
2
+ # Allow get method to returns value + entry's flags
3
+ # This is useful to set compression flag.
4
+ #
5
+
6
+ require 'memcached'
7
+
8
+ module LibmemcachedStore
9
+ class MemcachedWithFlags < Memcached
10
+ def get(keys, decode=true, with_flags=false)
11
+ if keys.is_a? Array
12
+ # inlined multi_get with changes to make it return flags and ignore cas
13
+ ret = Lib.memcached_mget(@struct, keys)
14
+ check_return_code(ret, keys)
15
+
16
+ hash = {}
17
+ flags_hash = {} if with_flags
18
+ value, key, flags, ret = Lib.memcached_fetch_rvalue(@struct)
19
+ while ret != 21 do # Lib::MEMCACHED_END
20
+ if ret == 0 # Lib::MEMCACHED_SUCCESS
21
+ flags_hash[key] = flags if with_flags
22
+ hash[key] = decode ? [value, flags] : value
23
+ elsif ret != 16 # Lib::MEMCACHED_NOTFOUND
24
+ check_return_code(ret, key)
25
+ end
26
+ value, key, flags, ret = Lib.memcached_fetch_rvalue(@struct)
27
+ end
28
+ if decode
29
+ hash.each do |key, value_and_flags|
30
+ hash[key] = @codec.decode(key, *value_and_flags)
31
+ end
32
+ end
33
+
34
+ # actual code we need
35
+ with_flags ? [hash, flags_hash] : hash
36
+ else
37
+ result = single_get(keys, decode)
38
+ with_flags ? result.first(2) : result.first
39
+ end
40
+ rescue => e
41
+ tries ||= 0
42
+ raise unless tries < options[:exception_retry_limit] && should_retry(e)
43
+ tries += 1
44
+ retry
45
+ end
46
+ end
47
+ end
@@ -1,3 +1,3 @@
1
1
  module LibmemcachedStore
2
- VERSION = "0.9.0"
2
+ VERSION = "0.10.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libmemcached_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Cocchi-Perrier
@@ -10,22 +10,22 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-10-24 00:00:00.000000000 Z
13
+ date: 2018-04-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: memcached
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - ">="
19
+ - - "~>"
20
20
  - !ruby/object:Gem::Version
21
- version: '0'
21
+ version: 1.8.0
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
- - - ">="
26
+ - - "~>"
27
27
  - !ruby/object:Gem::Version
28
- version: '0'
28
+ version: 1.8.0
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: rack
31
31
  requirement: !ruby/object:Gem::Requirement
@@ -131,6 +131,9 @@ dependencies:
131
131
  - - ">="
132
132
  - !ruby/object:Gem::Version
133
133
  version: '3'
134
+ - - "<"
135
+ - !ruby/object:Gem::Version
136
+ version: '5'
134
137
  type: :development
135
138
  prerelease: false
136
139
  version_requirements: !ruby/object:Gem::Requirement
@@ -138,6 +141,9 @@ dependencies:
138
141
  - - ">="
139
142
  - !ruby/object:Gem::Version
140
143
  version: '3'
144
+ - - "<"
145
+ - !ruby/object:Gem::Version
146
+ version: '5'
141
147
  - !ruby/object:Gem::Dependency
142
148
  name: actionpack
143
149
  requirement: !ruby/object:Gem::Requirement
@@ -145,6 +151,9 @@ dependencies:
145
151
  - - ">="
146
152
  - !ruby/object:Gem::Version
147
153
  version: '3'
154
+ - - "<"
155
+ - !ruby/object:Gem::Version
156
+ version: '5'
148
157
  type: :development
149
158
  prerelease: false
150
159
  version_requirements: !ruby/object:Gem::Requirement
@@ -152,6 +161,23 @@ dependencies:
152
161
  - - ">="
153
162
  - !ruby/object:Gem::Version
154
163
  version: '3'
164
+ - - "<"
165
+ - !ruby/object:Gem::Version
166
+ version: '5'
167
+ - !ruby/object:Gem::Dependency
168
+ name: single_cov
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
155
181
  description: |-
156
182
  An ActiveSupport cache store that uses the C-based libmemcached client through
157
183
  Evan Weaver's Ruby/SWIG wrapper, memcached. libmemcached is fast, lightweight,
@@ -165,8 +191,8 @@ files:
165
191
  - lib/active_support/cache/libmemcached_local_store.rb
166
192
  - lib/active_support/cache/libmemcached_store.rb
167
193
  - lib/libmemcached_store.rb
168
- - lib/memcached/get_with_flags.rb
169
- - lib/memcached/version.rb
194
+ - lib/libmemcached_store/memcached_with_flags.rb
195
+ - lib/libmemcached_store/version.rb
170
196
  homepage: https://github.com/ccocchi/libmemcached_store
171
197
  licenses:
172
198
  - MIT
@@ -179,7 +205,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
179
205
  requirements:
180
206
  - - ">="
181
207
  - !ruby/object:Gem::Version
182
- version: 2.0.0
208
+ version: 2.2.0
183
209
  required_rubygems_version: !ruby/object:Gem::Requirement
184
210
  requirements:
185
211
  - - ">="
@@ -187,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
187
213
  version: '0'
188
214
  requirements: []
189
215
  rubyforge_project:
190
- rubygems_version: 2.5.1
216
+ rubygems_version: 2.7.3
191
217
  signing_key:
192
218
  specification_version: 4
193
219
  summary: ActiveSupport 3+ cache store for the C-based libmemcached client
@@ -1,42 +0,0 @@
1
- #
2
- # Allow get method to returns value + entry's flags
3
- # This is useful to set compression flag.
4
- #
5
- module GetWithFlags
6
- def get(keys, marshal=true, with_flags=false)
7
- if keys.is_a? Array
8
- # Multi get
9
- ret = Memcached::Lib.memcached_mget(@struct, keys);
10
- check_return_code(ret, keys)
11
-
12
- hash, flags_hash = {}, {}
13
- value, key, flags, ret = Memcached::Lib.memcached_fetch_rvalue(@struct)
14
- while ret != 21 do # Lib::MEMCACHED_END
15
- if ret == 0 # Lib::MEMCACHED_SUCCESS
16
- hash[key] = value
17
- flags_hash[key] = flags if with_flags
18
- elsif ret != 16 # Lib::MEMCACHED_NOTFOUND
19
- check_return_code(ret, key)
20
- end
21
- value, key, flags, ret = Memcached::Lib.memcached_fetch_rvalue(@struct)
22
- end
23
- if marshal
24
- hash.each do |key, value|
25
- hash[key] = Marshal.load(value)
26
- end
27
- end
28
- with_flags ? [hash, flags_hash] : hash
29
- else
30
- # Single get
31
- value, flags, ret = Memcached::Lib.memcached_get_rvalue(@struct, keys)
32
- check_return_code(ret, keys)
33
- value = Marshal.load(value) if marshal
34
- with_flags ? [value, flags] : value
35
- end
36
- rescue => e
37
- tries ||= 0
38
- raise unless tries < options[:exception_retry_limit] && should_retry(e)
39
- tries += 1
40
- retry
41
- end
42
- end