hitnmiss 2.1.0 → 2.2.0.pre.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -0
- data/README.md +22 -4
- data/hitnmiss.gemspec +3 -2
- data/lib/hitnmiss.rb +1 -0
- data/lib/hitnmiss/background_refresh_repository.rb +13 -1
- data/lib/hitnmiss/repository.rb +1 -0
- data/lib/hitnmiss/version.rb +1 -1
- metadata +22 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff75002585412d720fd263df2de46c40a938b6e8
|
4
|
+
data.tar.gz: 0f32bfbe940cb194497f8fc7fe9ec07f1ff61faf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b30dd65528003dfb525ad21ef9019cad6e7f9919ae377b5262d8e5886471a07508c1405603ac023303187ee75615a39f346e6aa25f03285c002505daa657efc6
|
7
|
+
data.tar.gz: bd865b3b46ab573a274a4205bf956ffeb5e4557b969da4fcf4fc1b92d1c770fc17e6f251d1be4e6d470a3b30550c9bfbaa08ad97fd157745b665af88c9a48cae
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
[![Build Status](https://travis-ci.
|
2
|
-
[![Code Climate](https://codeclimate.com/
|
3
|
-
[![Test Coverage](https://codeclimate.com/
|
4
|
-
[![Issue Count](https://codeclimate.com/
|
1
|
+
[![Build Status](https://travis-ci.org/Acornsgrow/hitnmiss.svg?branch=master)](https://travis-ci.org/Acornsgrow/hitnmiss)
|
2
|
+
[![Code Climate](https://codeclimate.com/github/Acornsgrow/hitnmiss/badges/gpa.svg)](https://codeclimate.com/github/Acornsgrow/hitnmiss)
|
3
|
+
[![Test Coverage](https://codeclimate.com/github/Acornsgrow/hitnmiss/badges/coverage.svg)](https://codeclimate.com/github/Acornsgrow/hitnmiss/coverage)
|
4
|
+
[![Issue Count](https://codeclimate.com/github/Acornsgrow/hitnmiss/badges/issue_count.svg)](https://codeclimate.com/github/Acornsgrow/hitnmiss)
|
5
5
|
|
6
6
|
# Hitnmiss
|
7
7
|
|
@@ -179,6 +179,24 @@ end
|
|
179
179
|
|
180
180
|
This works exactly the same with the `Hitnmiss::BackgroundRefreshRepository`.
|
181
181
|
|
182
|
+
### Set a Logger
|
183
|
+
|
184
|
+
Hitnmiss defaults to not logging. However, if you would like to get detailed
|
185
|
+
logging from Hitnmiss you can do so by passing your application controlled
|
186
|
+
logger instance to the Hitnmiss repository. An example of this can be seen
|
187
|
+
below.
|
188
|
+
|
189
|
+
```ruby
|
190
|
+
class MostRecentPrice
|
191
|
+
include Hitnmiss::Repository
|
192
|
+
|
193
|
+
logger Logger.new(STDOUT)
|
194
|
+
end
|
195
|
+
```
|
196
|
+
|
197
|
+
**Note:** The above works exactly the same way for `Hitnmiss::Repository` and
|
198
|
+
`Hitnmiss::BackgroundRefreshRepository`.
|
199
|
+
|
182
200
|
### Define Fetcher Methods
|
183
201
|
|
184
202
|
You may be asking yourself, "How does the cache value get set?" Well,
|
data/hitnmiss.gemspec
CHANGED
@@ -6,8 +6,8 @@ require 'hitnmiss/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "hitnmiss"
|
8
8
|
spec.version = Hitnmiss::VERSION
|
9
|
-
spec.authors = ["Andrew De Ponte"]
|
10
|
-
spec.email = ["cyphactor@gmail.com"]
|
9
|
+
spec.authors = ["Andrew De Ponte", "Brian Miller", "Kyle Chong"]
|
10
|
+
spec.email = ["cyphactor@gmail.com", "brimil01@gmail.com", "me@kylechong.com"]
|
11
11
|
|
12
12
|
spec.summary = %q{Ruby read-through, write-behind caching using POROs}
|
13
13
|
spec.description = %q{Ruby gem to support using the Repository pattern for read-through, write-behind caching using POROs}
|
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
|
+
spec.add_dependency "optional_logger", "~> 2.0"
|
22
23
|
spec.add_development_dependency "bundler", "~> 1.11"
|
23
24
|
spec.add_development_dependency "rake", "~> 10.0"
|
24
25
|
spec.add_development_dependency "rspec", "~> 3.0"
|
data/lib/hitnmiss.rb
CHANGED
@@ -6,6 +6,7 @@ module Hitnmiss
|
|
6
6
|
class RefreshIntervalRequired < StandardError; end
|
7
7
|
|
8
8
|
def self.included(mod)
|
9
|
+
mod.extend(OptionalLogger::LoggerManagement)
|
9
10
|
mod.include(Repository::CacheManagement)
|
10
11
|
mod.extend(ClassMethods)
|
11
12
|
mod.include(InstanceMethods)
|
@@ -33,28 +34,39 @@ module Hitnmiss
|
|
33
34
|
end
|
34
35
|
|
35
36
|
def refresh(*args, swallow_exceptions: [])
|
37
|
+
self.class.logger.debug("hitnmiss: refresh(#{args.inspect}, swallow_exceptions: #{swallow_exceptions.inspect}) called")
|
36
38
|
if swallow_exceptions.empty?
|
39
|
+
self.class.logger.debug("hitnmiss: refresh(#{args.inspect}, swallow_exceptions: #{swallow_exceptions.inspect}) about to check stale?")
|
37
40
|
if stale?(*args)
|
41
|
+
self.class.logger.debug("hitnmiss: refresh(#{args.inspect}, swallow_exceptions: #{swallow_exceptions.inspect}) is stale, about to prime")
|
38
42
|
prime(*args)
|
39
43
|
end
|
40
44
|
else
|
41
45
|
begin
|
46
|
+
self.class.logger.debug("hitnmiss: refresh(#{args.inspect}, swallow_exceptions: #{swallow_exceptions.inspect}) about to check stale?")
|
42
47
|
if stale?(*args)
|
48
|
+
self.class.logger.debug("hitnmiss: refresh(#{args.inspect}, swallow_exceptions: #{swallow_exceptions.inspect}) is stale, about to prime")
|
43
49
|
prime(*args)
|
44
50
|
end
|
45
|
-
rescue *swallow_exceptions
|
51
|
+
rescue *swallow_exceptions => e
|
52
|
+
self.class.logger.error("hitnmiss: refresh(#{args.inspect}, swallow_exceptions: #{swallow_exceptions.inspect}) swallowed exception: #{e.inspect}")
|
53
|
+
self.class.logger.error(e.backtrace.join("\n"))
|
46
54
|
end
|
47
55
|
end
|
48
56
|
end
|
49
57
|
|
50
58
|
def background_refresh(*args, swallow_exceptions: [])
|
59
|
+
self.class.logger.debug("hitnmiss: background_refresh(#{args.inspect}) called")
|
51
60
|
@refresh_thread = Thread.new(self, args) do |repository, args|
|
52
61
|
while(true) do
|
62
|
+
repository.class.logger.debug("hitnmiss: background_refresh(#{args.inspect}): about to call refresh()")
|
53
63
|
refresh(*args, swallow_exceptions: swallow_exceptions)
|
64
|
+
repository.class.logger.debug("hitnmiss: background_refresh(#{args.inspect}): about to sleep for #{repository.class.refresh_interval}")
|
54
65
|
sleep repository.class.refresh_interval
|
55
66
|
end
|
56
67
|
end
|
57
68
|
@refresh_thread.abort_on_exception = true
|
69
|
+
self.class.logger.debug("hitnmiss: background_refresh(#{args.inspect}) enabled abort on exception")
|
58
70
|
end
|
59
71
|
|
60
72
|
private
|
data/lib/hitnmiss/repository.rb
CHANGED
data/lib/hitnmiss/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,31 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hitnmiss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0.pre.rc.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew De Ponte
|
8
|
+
- Brian Miller
|
9
|
+
- Kyle Chong
|
8
10
|
autorequire:
|
9
11
|
bindir: exe
|
10
12
|
cert_chain: []
|
11
|
-
date: 2016-
|
13
|
+
date: 2016-10-27 00:00:00.000000000 Z
|
12
14
|
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: optional_logger
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - "~>"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '2.0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - "~>"
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '2.0'
|
13
29
|
- !ruby/object:Gem::Dependency
|
14
30
|
name: bundler
|
15
31
|
requirement: !ruby/object:Gem::Requirement
|
@@ -98,6 +114,8 @@ description: Ruby gem to support using the Repository pattern for read-through,
|
|
98
114
|
caching using POROs
|
99
115
|
email:
|
100
116
|
- cyphactor@gmail.com
|
117
|
+
- brimil01@gmail.com
|
118
|
+
- me@kylechong.com
|
101
119
|
executables: []
|
102
120
|
extensions: []
|
103
121
|
extra_rdoc_files: []
|
@@ -145,9 +163,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
145
163
|
version: '0'
|
146
164
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
165
|
requirements:
|
148
|
-
- - "
|
166
|
+
- - ">"
|
149
167
|
- !ruby/object:Gem::Version
|
150
|
-
version:
|
168
|
+
version: 1.3.1
|
151
169
|
requirements: []
|
152
170
|
rubyforge_project:
|
153
171
|
rubygems_version: 2.5.1
|