readthis 1.0.0 → 1.1.0
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 +4 -4
- data/lib/readthis/cache.rb +2 -1
- data/lib/readthis/errors.rb +7 -0
- data/lib/readthis/serializers.rb +1 -4
- data/lib/readthis/version.rb +1 -1
- data/lib/readthis.rb +8 -0
- data/spec/readthis/cache_spec.rb +12 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c15a08e16c0c3499ba92207c32a0fb3cd07d6bea
|
4
|
+
data.tar.gz: 77b6b856ee036051b59a83c7a2013af49ef4c898
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1c2bd1bcadb0b1d4636de110c1202adf9f4c197bc189ef5282d86f4765612d5383ec9792d435b0629012732151e5a7468a965cc7d99a8b14e9e95100d6312af
|
7
|
+
data.tar.gz: 8ab80c80422fa2ad11d70e03ad6697c6a5d5d78fc76460b27cf1a332b023b9b0419c40020d291cc8db01638844dfe33a693c12a59e1d28474b9f858dc06998cf
|
data/lib/readthis/cache.rb
CHANGED
@@ -138,6 +138,7 @@ module Readthis
|
|
138
138
|
# cache.fetch('today', force: true) # => nil
|
139
139
|
#
|
140
140
|
def fetch(key, options = {})
|
141
|
+
options ||= {}
|
141
142
|
value = read(key, options) unless options[:force]
|
142
143
|
|
143
144
|
if value.nil? && block_given?
|
@@ -351,7 +352,7 @@ module Readthis
|
|
351
352
|
end
|
352
353
|
|
353
354
|
def merged_options(options)
|
354
|
-
(options || {})
|
355
|
+
@options.merge(options || {})
|
355
356
|
end
|
356
357
|
|
357
358
|
def pool_options(options)
|
data/lib/readthis/serializers.rb
CHANGED
@@ -1,11 +1,8 @@
|
|
1
1
|
require 'json'
|
2
|
+
require 'readthis/errors'
|
2
3
|
require 'readthis/passthrough'
|
3
4
|
|
4
5
|
module Readthis
|
5
|
-
SerializersFrozenError = Class.new(StandardError)
|
6
|
-
SerializersLimitError = Class.new(StandardError)
|
7
|
-
UnknownSerializerError = Class.new(StandardError)
|
8
|
-
|
9
6
|
class Serializers
|
10
7
|
BASE_SERIALIZERS = {
|
11
8
|
Marshal => 0x1,
|
data/lib/readthis/version.rb
CHANGED
data/lib/readthis.rb
CHANGED
@@ -1,10 +1,18 @@
|
|
1
1
|
require 'readthis/cache'
|
2
|
+
require 'readthis/errors'
|
2
3
|
require 'readthis/serializers'
|
3
4
|
require 'readthis/version'
|
4
5
|
|
5
6
|
module Readthis
|
6
7
|
extend self
|
7
8
|
|
9
|
+
# The current, global, instance of serializers that is used by all cache
|
10
|
+
# instances.
|
11
|
+
#
|
12
|
+
# @returns [Readthis::Serializers] An cached Serializers instance
|
13
|
+
#
|
14
|
+
# @see readthis/serializers
|
15
|
+
#
|
8
16
|
def serializers
|
9
17
|
@serializers ||= Readthis::Serializers.new
|
10
18
|
end
|
data/spec/readthis/cache_spec.rb
CHANGED
@@ -48,11 +48,16 @@ RSpec.describe Readthis::Cache do
|
|
48
48
|
end
|
49
49
|
|
50
50
|
it 'uses a custom expiration' do
|
51
|
-
cache.
|
51
|
+
cache = Readthis::Cache.new(namespace: 'cache', expires_in: 86400)
|
52
|
+
|
53
|
+
cache.write('some-key', 'some-value')
|
54
|
+
cache.write('other-key', 'other-value', expires_in: 1)
|
52
55
|
|
53
56
|
expect(cache.read('some-key')).not_to be_nil
|
57
|
+
expect(cache.read('other-key')).not_to be_nil
|
54
58
|
sleep 1.01
|
55
|
-
expect(cache.read('some-key')).
|
59
|
+
expect(cache.read('some-key')).not_to be_nil
|
60
|
+
expect(cache.read('other-key')).to be_nil
|
56
61
|
end
|
57
62
|
|
58
63
|
it 'expands non-string keys' do
|
@@ -156,6 +161,11 @@ RSpec.describe Readthis::Cache do
|
|
156
161
|
|
157
162
|
expect(cache.read('short-key')).to eq('other stuff')
|
158
163
|
end
|
164
|
+
|
165
|
+
it 'gets an existing value when `options` are passed as nil' do
|
166
|
+
cache.write('great-key', 'great')
|
167
|
+
expect(cache.fetch('great-key', nil)).to eq('great')
|
168
|
+
end
|
159
169
|
end
|
160
170
|
|
161
171
|
describe '#read_multi' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: readthis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.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: 2015-
|
11
|
+
date: 2015-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|
@@ -120,6 +120,7 @@ files:
|
|
120
120
|
- lib/readthis.rb
|
121
121
|
- lib/readthis/cache.rb
|
122
122
|
- lib/readthis/entity.rb
|
123
|
+
- lib/readthis/errors.rb
|
123
124
|
- lib/readthis/expanders.rb
|
124
125
|
- lib/readthis/passthrough.rb
|
125
126
|
- lib/readthis/serializers.rb
|