svelte-on-rails 4.0.3 → 4.0.5
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/svelte_on_rails/lib/view_helper_support.rb +19 -17
- data/lib/svelte_on_rails/view_helpers.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76f5c610ec395c501a54cfb72bd6f1acc7f515b2a9c6013a0376dc20b869fc40
|
4
|
+
data.tar.gz: 5d33bfe29859bd3dff0b2ba84a33407435d1092dc55fa578c287b2ce6d3241f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 371b860a44e4b719c3faa5f4bec97a9629d11381a0bb8df975d7978b5d5a782b17f5f7db2c95d9eae4873634b2923c011a35c8d01c5371f85aeb3d660e160061
|
7
|
+
data.tar.gz: e3f586486a45ac0145c0fe6ce29d721710ee2d24e917522aadd40af9fd3012432a576dea1cfd6d3c2a3c91cd7d29488aae3811054f4eda13587f3d7b6208025d
|
@@ -101,6 +101,24 @@ module SvelteOnRails
|
|
101
101
|
renderer.render(@props)
|
102
102
|
end
|
103
103
|
|
104
|
+
def custom_cache_key
|
105
|
+
if @helper_options[:cache_key]
|
106
|
+
k2 = (@helper_options[:cache_key])
|
107
|
+
keys = k2.is_a?(Array) ? k2 : [k2]
|
108
|
+
keys.map do |k|
|
109
|
+
if k.is_a?(ActiveRecord::Base)
|
110
|
+
"#{k.class.name}#{k.id}"
|
111
|
+
elsif k == nil
|
112
|
+
'nil'
|
113
|
+
elsif k.present?
|
114
|
+
k.to_s
|
115
|
+
else
|
116
|
+
"empty-#{k.class}"
|
117
|
+
end
|
118
|
+
end.join('-')
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
104
122
|
private
|
105
123
|
|
106
124
|
def validate_file
|
@@ -132,26 +150,10 @@ module SvelteOnRails
|
|
132
150
|
mtime_file = @conf.ssr_dist_folder.join('last_mtime')
|
133
151
|
mtime = File.read(mtime_file)
|
134
152
|
|
135
|
-
key2 = if @helper_options[:cache_key]
|
136
|
-
k2 = (@helper_options[:cache_key])
|
137
|
-
keys = k2.is_a?(Array) ? k2 : [k2]
|
138
|
-
keys.map do |k|
|
139
|
-
if k.is_a?(ActiveRecord::Base)
|
140
|
-
"#{k.class.name}#{k.id}"
|
141
|
-
elsif k == nil
|
142
|
-
'nil'
|
143
|
-
elsif k.present?
|
144
|
-
k.to_s
|
145
|
-
else
|
146
|
-
"empty-#{k.class}"
|
147
|
-
end
|
148
|
-
end.join('-')
|
149
|
-
end
|
150
|
-
|
151
153
|
filename_part = [
|
152
154
|
"#{filename.split('/').last}.svelte",
|
153
155
|
Zlib.crc32(filename).to_s(36),
|
154
|
-
|
156
|
+
custom_cache_key
|
155
157
|
].compact.join('-')
|
156
158
|
|
157
159
|
@cache_key_primary = [
|
@@ -29,7 +29,7 @@ module SvelteOnRails
|
|
29
29
|
# TTL
|
30
30
|
if support.debug?
|
31
31
|
|
32
|
-
support.debug_log("Rendering component:
|
32
|
+
support.debug_log("Rendering component: «#{filename}», cache_key: «#{support.custom_cache_key}»")
|
33
33
|
support.debug_log("Redis configuration: #{support.conf.redis_cache_store}")
|
34
34
|
ttl = redis.ttl(support.cache_key)
|
35
35
|
|
@@ -62,7 +62,7 @@ module SvelteOnRails
|
|
62
62
|
|
63
63
|
redis.scan_each(match: "#{support.cache_key_primary}:*") do |key|
|
64
64
|
redis.del(key)
|
65
|
-
support.debug_log("deleted cache: #{key}")
|
65
|
+
support.debug_log("deleted cache, pattern: «#{support.cache_key_primary}:*», key: #{key.sub("#{support.cache_key_primary}:", '[..]')}")
|
66
66
|
end
|
67
67
|
|
68
68
|
redis.set(support.cache_key, r)
|