readthis 2.0.2 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/readthis/cache.rb +6 -6
- data/lib/readthis/entity.rb +7 -7
- data/lib/readthis/serializers.rb +2 -2
- data/lib/readthis/version.rb +1 -1
- data/spec/readthis/cache_spec.rb +1 -1
- metadata +11 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7b4dfe48dce8fa54170963b720ee202dedb19df
|
4
|
+
data.tar.gz: 0e611efe5dcd71df78491618472a0394ec408a69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f436a2f365f761d8be21ee93041f65b990b2f2ea92d8e95486bc127dbe8f4f3a27cad1250237a0cc1a8314e8b6992ab6698e6a8f9455e1d89ab4dab2b5b3148
|
7
|
+
data.tar.gz: 9e18f5b63c9bfc05b1e1e8f110a7957a7d9c6cedb70868e91c810509e42a93985b0fd6d84619c4880e58398d63d5a2e1ed0def088a760849d4dbd1275dd9c4f8
|
data/lib/readthis/cache.rb
CHANGED
@@ -51,8 +51,8 @@ module Readthis
|
|
51
51
|
@options = options
|
52
52
|
|
53
53
|
@entity = Readthis::Entity.new(
|
54
|
-
marshal:
|
55
|
-
compress:
|
54
|
+
marshal: options.fetch(:marshal, Marshal),
|
55
|
+
compress: options.fetch(:compress, false),
|
56
56
|
threshold: options.fetch(:compression_threshold, 1024)
|
57
57
|
)
|
58
58
|
|
@@ -152,8 +152,8 @@ module Readthis
|
|
152
152
|
namespaced = namespaced_key(pattern, merged_options(options))
|
153
153
|
|
154
154
|
invoke(:delete, pattern) do |store|
|
155
|
-
cursor
|
156
|
-
count
|
155
|
+
cursor = nil
|
156
|
+
count = options.fetch(:count, 1000)
|
157
157
|
deleted = 0
|
158
158
|
|
159
159
|
until cursor == '0'.freeze
|
@@ -419,7 +419,7 @@ module Readthis
|
|
419
419
|
|
420
420
|
def instrument(name, key)
|
421
421
|
if self.class.notifications
|
422
|
-
name
|
422
|
+
name = "cache_#{name}.active_support"
|
423
423
|
payload = { key: key, name: name }
|
424
424
|
|
425
425
|
self.class.notifications.instrument(name, payload) { yield(payload) }
|
@@ -453,7 +453,7 @@ module Readthis
|
|
453
453
|
end
|
454
454
|
|
455
455
|
def pool_options(options)
|
456
|
-
{ size:
|
456
|
+
{ size: options.fetch(:pool_size, 5),
|
457
457
|
timeout: options.fetch(:pool_timeout, 5) }
|
458
458
|
end
|
459
459
|
|
data/lib/readthis/entity.rb
CHANGED
@@ -7,8 +7,8 @@ module Readthis
|
|
7
7
|
# Unless they are overridden, these are the options used to load and unload
|
8
8
|
# every value.
|
9
9
|
DEFAULT_OPTIONS = {
|
10
|
-
compress:
|
11
|
-
marshal:
|
10
|
+
compress: false,
|
11
|
+
marshal: Marshal,
|
12
12
|
threshold: 8 * 1024
|
13
13
|
}.freeze
|
14
14
|
|
@@ -55,8 +55,8 @@ module Readthis
|
|
55
55
|
# entity.dump(string, compress: false, marshal: JSON)
|
56
56
|
#
|
57
57
|
def dump(value, options = {})
|
58
|
-
compress
|
59
|
-
marshal
|
58
|
+
compress = with_fallback(options, :compress)
|
59
|
+
marshal = with_fallback(options, :marshal)
|
60
60
|
threshold = with_fallback(options, :threshold)
|
61
61
|
|
62
62
|
dumped = deflate(marshal.dump(value), compress, threshold)
|
@@ -97,10 +97,10 @@ module Readthis
|
|
97
97
|
# @example Compose an option embedded string
|
98
98
|
#
|
99
99
|
# entity.compose(string, Marshal, false) => 0x1 + string
|
100
|
-
# entity.compose(string, JSON, true)
|
100
|
+
# entity.compose(string, JSON, true) => 0x10 + string
|
101
101
|
#
|
102
102
|
def compose(value, marshal, compress)
|
103
|
-
flags
|
103
|
+
flags = serializers.assoc(marshal)
|
104
104
|
flags |= COMPRESSED_FLAG if compress
|
105
105
|
|
106
106
|
value.prepend([flags].pack('C'))
|
@@ -116,7 +116,7 @@ module Readthis
|
|
116
116
|
flags = string[0].unpack('C').first
|
117
117
|
|
118
118
|
if flags < 16
|
119
|
-
marshal
|
119
|
+
marshal = serializers.rassoc(flags)
|
120
120
|
compress = (flags & COMPRESSED_FLAG) != 0
|
121
121
|
|
122
122
|
[marshal, compress, string[1..-1]]
|
data/lib/readthis/serializers.rb
CHANGED
@@ -7,9 +7,9 @@ module Readthis
|
|
7
7
|
# Defines the default set of three serializers: Marshal, Passthrough, and
|
8
8
|
# JSON. With a hard limit of 7 that leaves 4 additional slots.
|
9
9
|
BASE_SERIALIZERS = {
|
10
|
-
Marshal
|
10
|
+
Marshal => 0x1,
|
11
11
|
Passthrough => 0x2,
|
12
|
-
JSON
|
12
|
+
JSON => 0x3
|
13
13
|
}.freeze
|
14
14
|
|
15
15
|
# The hard serializer limit, based on the number of possible values within
|
data/lib/readthis/version.rb
CHANGED
data/spec/readthis/cache_spec.rb
CHANGED
@@ -22,7 +22,7 @@ RSpec.describe Readthis::Cache do
|
|
22
22
|
cache = Readthis::Cache.new(redis: { driver: :hiredis })
|
23
23
|
|
24
24
|
cache.pool.with do |client|
|
25
|
-
expect(client.
|
25
|
+
expect(client._client.driver).to be(Redis::Connection::Hiredis)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: readthis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Parker Selbert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '3.0'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '5.0'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '3.0'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '5.0'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: connection_pool
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -156,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
162
|
version: '0'
|
157
163
|
requirements: []
|
158
164
|
rubyforge_project:
|
159
|
-
rubygems_version: 2.5.1
|
165
|
+
rubygems_version: 2.5.2.1
|
160
166
|
signing_key:
|
161
167
|
specification_version: 4
|
162
168
|
summary: Pooled active support compliant caching with redis
|
@@ -170,4 +176,3 @@ test_files:
|
|
170
176
|
- spec/readthis/serializers_spec.rb
|
171
177
|
- spec/readthis_spec.rb
|
172
178
|
- spec/spec_helper.rb
|
173
|
-
has_rdoc:
|