async_cache 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.yardopts +4 -0
- data/Gemfile.lock +5 -1
- data/Rakefile +5 -0
- data/async_cache.gemspec +2 -0
- data/lib/async_cache/store.rb +14 -1
- data/lib/async_cache/version.rb +1 -1
- data/lib/async_cache/workers/base.rb +12 -6
- metadata +32 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 500e9448eef871f617a1d0a131fd3838c231058d
|
4
|
+
data.tar.gz: 3f09a314542ea93102d65d96e6417f25374483d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e174c76425afb575ace71b4902b6b7fcb6acc9d2b096fc4955e0a0c88c738c4441e83529d274243dd40d2360c5f265bc69e267c4773558e2587a5849311da30a
|
7
|
+
data.tar.gz: 51e30ffe8cb929710185ee2624e6a957a33b33338a3724f317414597bf75786f7b96944abf02a3878212fd7daa85137b3cbe39f58ed2d56e3e8b73ba5f637bab
|
data/.yardopts
ADDED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
async_cache (1.0.
|
4
|
+
async_cache (1.0.2)
|
5
5
|
sourcify (~> 0.5.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -122,6 +122,7 @@ GEM
|
|
122
122
|
rake (>= 0.8.7)
|
123
123
|
thor (>= 0.18.1, < 2.0)
|
124
124
|
rake (10.4.2)
|
125
|
+
redcarpet (3.3.4)
|
125
126
|
redis (3.2.1)
|
126
127
|
redis-activesupport (4.1.5)
|
127
128
|
activesupport (>= 3, < 5)
|
@@ -184,6 +185,7 @@ GEM
|
|
184
185
|
tins (1.8.1)
|
185
186
|
tzinfo (1.2.2)
|
186
187
|
thread_safe (~> 0.1)
|
188
|
+
yard (0.8.7.6)
|
187
189
|
|
188
190
|
PLATFORMS
|
189
191
|
ruby
|
@@ -193,11 +195,13 @@ DEPENDENCIES
|
|
193
195
|
httparty (~> 0.13.7)
|
194
196
|
pry (~> 0.10.1)
|
195
197
|
rails (~> 4.2.4)
|
198
|
+
redcarpet (~> 3.3.4)
|
196
199
|
redis-activesupport (~> 4.1.5)
|
197
200
|
rspec (~> 3.4.0)
|
198
201
|
sidekiq (~> 3.5.2)
|
199
202
|
simplecov (~> 0.9.2)
|
200
203
|
sinatra (~> 1.4.6)
|
204
|
+
yard (~> 0.8)
|
201
205
|
|
202
206
|
BUNDLED WITH
|
203
207
|
1.11.2
|
data/Rakefile
CHANGED
data/async_cache.gemspec
CHANGED
@@ -23,6 +23,8 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.add_development_dependency 'simplecov', '~> 0.9.2'
|
24
24
|
s.add_development_dependency 'redis-activesupport', '~> 4.1.5'
|
25
25
|
s.add_development_dependency 'httparty', '~> 0.13.7'
|
26
|
+
s.add_development_dependency 'yard', '~> 0.8'
|
27
|
+
s.add_development_dependency 'redcarpet', '~> 3.3.4'
|
26
28
|
|
27
29
|
s.files = `git ls-files`.split("\n")
|
28
30
|
s.test_files = `git ls-files -- test/*`.split("\n")
|
data/lib/async_cache/store.rb
CHANGED
@@ -2,6 +2,12 @@ module AsyncCache
|
|
2
2
|
class Store
|
3
3
|
attr_accessor :backend, :worker_klass
|
4
4
|
|
5
|
+
# @param [Hash] opts Initialization options
|
6
|
+
# @option opts [Object] :backend The backend that it will read/write
|
7
|
+
# entries to/from
|
8
|
+
# @option opts [Symbol] :worker Shorthand symbol for the worker to use,
|
9
|
+
# options are `:active_job` and `:sidekiq`.
|
10
|
+
# @option ops [Class] :worker_klass Class of the worker to use.
|
5
11
|
def initialize(opts = {})
|
6
12
|
@worker_klass =
|
7
13
|
if opts[:worker_klass]
|
@@ -15,6 +21,10 @@ module AsyncCache
|
|
15
21
|
@backend = opts[:backend] || AsyncCache.backend
|
16
22
|
end
|
17
23
|
|
24
|
+
# @param [String] locator The constant locator for the entry in the cache
|
25
|
+
# @param [Fixnum] version Version of the value identified by that locator
|
26
|
+
# @param [Hash] options
|
27
|
+
# @yield [*arguments in options[:arguments]] Called if entry out-of-date
|
18
28
|
def fetch(locator, version, options = {}, &block)
|
19
29
|
options = options.dup # Duplicate to avoid side effects
|
20
30
|
version = version.to_i # Versions must *always* be convertible to integers
|
@@ -103,13 +113,16 @@ module AsyncCache
|
|
103
113
|
|
104
114
|
private
|
105
115
|
|
106
|
-
#
|
116
|
+
# Ensures the arguments are primitives.
|
107
117
|
def check_arguments arguments
|
108
118
|
arguments.each_with_index do |argument, index|
|
109
119
|
next if argument.is_a? Numeric
|
110
120
|
next if argument.is_a? String
|
111
121
|
next if argument.is_a? Symbol
|
112
122
|
next if argument.is_a? Hash
|
123
|
+
next if argument.is_a? NilClass
|
124
|
+
next if argument.is_a? TrueClass
|
125
|
+
next if argument.is_a? FalseClass
|
113
126
|
|
114
127
|
raise ArgumentError, "Cannot send complex data for block argument #{index + 1}: #{argument.class.name}"
|
115
128
|
end
|
data/lib/async_cache/version.rb
CHANGED
@@ -15,20 +15,26 @@ module AsyncCache
|
|
15
15
|
|
16
16
|
module Base
|
17
17
|
# Abstract public interface to workers that process AsyncCache jobs
|
18
|
+
|
19
|
+
# @return [Boolean] Returns whether or not workers are running to
|
20
|
+
# process enqueue AsyncCache jobs. Return `false` if this
|
21
|
+
# functionality isn't available by the underlying system.
|
18
22
|
def self.has_workers?
|
19
23
|
raise NotImplementedError
|
20
24
|
end
|
21
25
|
|
26
|
+
# Public interface for enqueuing jobs. This is what is called by
|
27
|
+
# {AsyncCache::Store}.
|
22
28
|
def self.enqueue_async_job(key:, version:, expires_in:, block:, arguments:)
|
23
29
|
raise NotImplementedError
|
24
30
|
end
|
25
31
|
|
26
|
-
# key
|
27
|
-
# version
|
28
|
-
#
|
29
|
-
# expires_in
|
30
|
-
# block_arguments
|
31
|
-
# block_source
|
32
|
+
# @param [String] key String or array cache key computed by `AsyncCache`
|
33
|
+
# @param [Fixnum] version Monotonically increasing integer indicating
|
34
|
+
# the version of the resource being cached
|
35
|
+
# @param [Fixnum] expires_in Optional expiration to pass to the cache store
|
36
|
+
# @param [Array] block_arguments Arguments with which to call the block
|
37
|
+
# @param [String] block_source Ruby source to evaluate to produce the value
|
32
38
|
def perform key, version, expires_in, block_arguments, block_source
|
33
39
|
t0 = Time.now
|
34
40
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async_cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Derewecki
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-01-
|
12
|
+
date: 2016-01-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sourcify
|
@@ -137,6 +137,34 @@ dependencies:
|
|
137
137
|
- - "~>"
|
138
138
|
- !ruby/object:Gem::Version
|
139
139
|
version: 0.13.7
|
140
|
+
- !ruby/object:Gem::Dependency
|
141
|
+
name: yard
|
142
|
+
requirement: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - "~>"
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0.8'
|
147
|
+
type: :development
|
148
|
+
prerelease: false
|
149
|
+
version_requirements: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - "~>"
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0.8'
|
154
|
+
- !ruby/object:Gem::Dependency
|
155
|
+
name: redcarpet
|
156
|
+
requirement: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - "~>"
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: 3.3.4
|
161
|
+
type: :development
|
162
|
+
prerelease: false
|
163
|
+
version_requirements: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - "~>"
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: 3.3.4
|
140
168
|
description:
|
141
169
|
email:
|
142
170
|
- derewecki@gmail.com
|
@@ -148,6 +176,7 @@ files:
|
|
148
176
|
- ".gitignore"
|
149
177
|
- ".rspec"
|
150
178
|
- ".travis.yml"
|
179
|
+
- ".yardopts"
|
151
180
|
- Gemfile
|
152
181
|
- Gemfile.lock
|
153
182
|
- LICENSE
|
@@ -196,3 +225,4 @@ signing_key:
|
|
196
225
|
specification_version: 4
|
197
226
|
summary: Pattern and library for implementing asynchronous caching
|
198
227
|
test_files: []
|
228
|
+
has_rdoc:
|