cache_keeper 0.5.1 → 0.6.1
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/README.md +8 -0
- data/app/jobs/cache_keeper/active_job_parent_class.rb +3 -0
- data/app/jobs/cache_keeper/base_job.rb +1 -1
- data/app/serializers/cache_keeper/marshal_serializer.rb +2 -2
- data/lib/cache_keeper/configuration.rb +5 -0
- data/lib/cache_keeper/version.rb +1 -1
- data/test/serializers/marshal_serializer_test.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 919ef367b49336174acda56328421939872f1921ec23d349fedca66e23a01815
|
4
|
+
data.tar.gz: 2cdf9e582968a16557b06534a28d77298957b1474a04c552fffa7e130015b6e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72094507997a5a056faa3e61438f1725d7e9787bf4ce4b710a1d071c55a9e93f576c5ff680d88940838a69f38aef1ef9b6aad9e43f74f7e8a5104180d5d910cb
|
7
|
+
data.tar.gz: 585089805bde2aa9ec878d4c0e01ed1eb5f73d9a28fb98e51e1b83e34ea4db1de3f274849d6f6427e25e7263d2c3a7f945277ebaec67643823ba78f1e6566dc3
|
data/README.md
CHANGED
@@ -59,6 +59,8 @@ CacheKeeper will compose cache keys from the name of the method and the instance
|
|
59
59
|
|
60
60
|
```ruby
|
61
61
|
class NebulaNoodleTwister
|
62
|
+
include CacheKeeper::Caching
|
63
|
+
|
62
64
|
caches :twist_noodles, :dish_of_the_day, key: ->(method_name) { [:recoding, id, method_name] }
|
63
65
|
caches :synchronize_taste_buds, key: -> { [:recoding, id, :synchronize_taste_buds] }
|
64
66
|
caches :space_soup_simulation, key: :space_soup_simulation
|
@@ -71,6 +73,8 @@ CacheKeeper needs to pass the instance on which the cached method is called alon
|
|
71
73
|
|
72
74
|
```ruby
|
73
75
|
class QuantumQuackerator
|
76
|
+
include CacheKeeper::Caching
|
77
|
+
|
74
78
|
# Generate a new instance using an empty initializer (QuantumQuackerator.new)
|
75
79
|
# Useful for controllers and for POROs with no arguments
|
76
80
|
caches :quackify_particles, serializer: :new_instance
|
@@ -123,6 +127,10 @@ Rails.application.configure do
|
|
123
127
|
# The queue to use for the refresh jobs.
|
124
128
|
# Default: nil (uses the default queue)
|
125
129
|
config.cache_keeper.queues.refresh = :low_priority
|
130
|
+
|
131
|
+
# The parent class of the refresh jobs.
|
132
|
+
# Default: "ActiveJob::Base"
|
133
|
+
config.cache_keeper.active_job_parent_class = "ApplicationJob"
|
126
134
|
end
|
127
135
|
```
|
128
136
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
class CacheKeeper::MarshalSerializer < ActiveJob::Serializers::ObjectSerializer
|
2
2
|
def serialize(target)
|
3
|
-
super("dump" => Marshal.dump(target)
|
3
|
+
super("dump" => Base64.encode64(Marshal.dump(target)))
|
4
4
|
end
|
5
5
|
|
6
6
|
def deserialize(json)
|
7
|
-
Marshal.load(json["dump"]
|
7
|
+
Marshal.load Base64.decode64(json["dump"])
|
8
8
|
end
|
9
9
|
end
|
@@ -2,6 +2,7 @@ module CacheKeeper
|
|
2
2
|
class Configuration
|
3
3
|
DEFAULT_MUST_REVALIDATE = false
|
4
4
|
DEFAULT_QUEUES = {}.freeze
|
5
|
+
DEFAULT_ACTIVE_JOB_PARENT_CLASS = "ActiveJob::Base".freeze
|
5
6
|
|
6
7
|
def must_revalidate
|
7
8
|
return rails_config.must_revalidate unless rails_config.must_revalidate.nil?
|
@@ -13,6 +14,10 @@ module CacheKeeper
|
|
13
14
|
rails_config.queues || DEFAULT_QUEUES
|
14
15
|
end
|
15
16
|
|
17
|
+
def active_job_parent_class
|
18
|
+
rails_config.active_job_parent_class || DEFAULT_ACTIVE_JOB_PARENT_CLASS
|
19
|
+
end
|
20
|
+
|
16
21
|
private
|
17
22
|
|
18
23
|
def rails_config
|
data/lib/cache_keeper/version.rb
CHANGED
@@ -5,7 +5,7 @@ class CacheKeeper::MarshalSerializerTest < ActiveSupport::TestCase
|
|
5
5
|
target = Recording.new
|
6
6
|
serialized = serializer.serialize(target)
|
7
7
|
|
8
|
-
assert_equal serialized["dump"], Marshal.dump(target)
|
8
|
+
assert_equal serialized["dump"], Base64.encode64(Marshal.dump(target))
|
9
9
|
end
|
10
10
|
|
11
11
|
test "deserializes the marshal dump" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cache_keeper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Zamuner
|
@@ -36,6 +36,7 @@ files:
|
|
36
36
|
- Gemfile
|
37
37
|
- MIT-LICENSE
|
38
38
|
- README.md
|
39
|
+
- app/jobs/cache_keeper/active_job_parent_class.rb
|
39
40
|
- app/jobs/cache_keeper/autorefresh_job.rb
|
40
41
|
- app/jobs/cache_keeper/base_job.rb
|
41
42
|
- app/jobs/cache_keeper/refresh_job.rb
|