cache_json 1.2.3 → 1.2.4
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/Gemfile.lock +1 -1
- data/README.md +2 -1
- data/lib/cache_json/adapters/redis.rb +4 -0
- data/lib/cache_json/base.rb +9 -0
- data/lib/cache_json/version.rb +1 -1
- data/lib/cache_json/worker.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a2871967748d37f7dcca4cc282329618481c1a94e927a91d0edef8dd261e787
|
4
|
+
data.tar.gz: 7bf987cd4de3a9a6067ba22e138fec40dd445fa84fbc3770cb78ccb14f409a5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55429caa296c0ff0e0ec826a1de86be8cbad241f4957a1bb7d90498c36dfa3e8cb8a215725271a3c540bcf3e8a87b26198d3460697d1c24015ddc7f89989948d
|
7
|
+
data.tar.gz: 7fa105bcbffc4400dbd949b8c64b0b885b868d0e031a2d4047dc33ec8060ec7b40459a55879c6475581836d35ec5d198adc4f8e6e676077d8b97507cc6680e6f
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -67,6 +67,7 @@ class ExpensiveJob
|
|
67
67
|
cache_json_options(
|
68
68
|
time_to_expire: 1.hour,
|
69
69
|
refresh: {
|
70
|
+
buffer: 5.minutes,
|
70
71
|
arguments: {
|
71
72
|
first: (5..10),
|
72
73
|
second: ['one option', 'another option'],
|
@@ -89,7 +90,7 @@ cache_json_worker:
|
|
89
90
|
class: CacheJSON::Worker
|
90
91
|
```
|
91
92
|
|
92
|
-
Whenever the worker runs, it checks which results have expired, and refreshes only those.
|
93
|
+
Whenever the worker runs, it checks which results have expired, and refreshes only those. If you pass in the `buffer` option, it will actually refresh keys that are that far away from expiring. In the example above, the worker will refresh the cache 5 minutes before it expires. This is good if you want to avoid cache misses altogether.
|
93
94
|
|
94
95
|
## Development
|
95
96
|
|
data/lib/cache_json/base.rb
CHANGED
@@ -17,6 +17,11 @@ module CacheJSON
|
|
17
17
|
JSON.parse(refresh_cache!(args: args, cache: cache).to_json) # stringify keys
|
18
18
|
end
|
19
19
|
|
20
|
+
def cache_expiring_soon?(args:, cache: nil)
|
21
|
+
cache ||= Cache.new(args: args, options: self.class.cache_json_full_options)
|
22
|
+
cache.cache_expiring_soon?
|
23
|
+
end
|
24
|
+
|
20
25
|
def clear_cache!
|
21
26
|
Cache.new(options: self.class.cache_json_full_options).clear_cache!
|
22
27
|
end
|
@@ -54,6 +59,10 @@ module CacheJSON
|
|
54
59
|
adapter.clear_cache!
|
55
60
|
end
|
56
61
|
|
62
|
+
def cache_expiring_soon?
|
63
|
+
adapter.cache_expiring_soon?
|
64
|
+
end
|
65
|
+
|
57
66
|
def adapter
|
58
67
|
@adapter ||= CacheJSON::Adapters::Redis.new(args: args, options: options)
|
59
68
|
end
|
data/lib/cache_json/version.rb
CHANGED
data/lib/cache_json/worker.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cache_json
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Gut
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
11
|
+
date: 2020-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|