svelte-on-rails 4.0.3 → 4.0.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/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: 569ed5c0fc5d0a3f5e62f25c575b1a341ac39691a11855745eef885640cd3959
|
4
|
+
data.tar.gz: 96b0e5071f4bf398156ce33725b4f1020e9658842a7becf3cb898c78a86ad04a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8241556777b1b0a39625c743b43fcb7b7cbb4c792218167ea057f62b2467a324b6594a7f55a5cad4f7943e455070a2b03fb5a393ad2785913866f052e728620f
|
7
|
+
data.tar.gz: 1e7061b8dfc64e2b5a5700d58a588c377702f3e290cb24b69a80bc2c09e2e6b8ed27f89f6759d8420005c2815c0b0675c9b05d674f156e7d9a5b35cb8f5a3e1a
|
@@ -127,31 +127,33 @@ module SvelteOnRails
|
|
127
127
|
_ssr == :auto ? request.headers[conf.non_ssr_request_header].blank? : _ssr
|
128
128
|
end
|
129
129
|
|
130
|
+
def custom_cache_key
|
131
|
+
if @helper_options[:cache_key]
|
132
|
+
k2 = (@helper_options[:cache_key])
|
133
|
+
keys = k2.is_a?(Array) ? k2 : [k2]
|
134
|
+
keys.map do |k|
|
135
|
+
if k.is_a?(ActiveRecord::Base)
|
136
|
+
"#{k.class.name}#{k.id}"
|
137
|
+
elsif k == nil
|
138
|
+
'nil'
|
139
|
+
elsif k.present?
|
140
|
+
k.to_s
|
141
|
+
else
|
142
|
+
"empty-#{k.class}"
|
143
|
+
end
|
144
|
+
end.join('-')
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
130
148
|
def generate_cache_key
|
131
149
|
|
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)
|