svelte-on-rails 4.0.1 → 4.0.2
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 +11 -1
- data/lib/svelte_on_rails/view_helpers.rb +20 -6
- 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: a04f321576291cd2c8663dd72fb181438a64e678151a48cce151fab567cb63be
|
4
|
+
data.tar.gz: 896d0ca8348e9ef37cfd5ba61fef9ea51a9c315e14afb0fd6a4f2c6472737ae1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eed1857d6d317005ba1f87afe6ec79f1a003823f6a84351fa14abb8fa29c46454ab71ed8496e387ee8faec48235f71203b0562f0b24b560236701c4afbe2e90e
|
7
|
+
data.tar.gz: aedb4fb0928a82b0d53426603d15604b64fc664c61e93b28040b9f8b52d5f1e319a14bbb81b2c6d1cce8da1292e46632ce038f24f6f098a71637ebb1d7ef2f4b
|
@@ -135,7 +135,17 @@ module SvelteOnRails
|
|
135
135
|
key2 = if @helper_options[:cache_key]
|
136
136
|
k2 = (@helper_options[:cache_key])
|
137
137
|
keys = k2.is_a?(Array) ? k2 : [k2]
|
138
|
-
keys.map
|
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.join('-')
|
148
|
+
end
|
139
149
|
end
|
140
150
|
|
141
151
|
filename_part = [
|
@@ -22,20 +22,34 @@ module SvelteOnRails
|
|
22
22
|
|
23
23
|
support = SvelteOnRails::Lib::ViewHelperSupport.new(filename, props, request, true)
|
24
24
|
|
25
|
-
support.debug_log("Rendering component: #{filename}")
|
26
25
|
log_message = '?'
|
27
26
|
redis = support.conf.redis_instance
|
28
|
-
|
29
|
-
support.debug_log("Redis configuration: #{support.conf.redis_cache_store}")
|
27
|
+
cached_content = redis.get(support.cache_key)
|
30
28
|
|
31
29
|
# TTL
|
32
30
|
if support.debug?
|
31
|
+
|
32
|
+
support.debug_log("Rendering component: #{filename}")
|
33
|
+
support.debug_log("Redis configuration: #{support.conf.redis_cache_store}")
|
33
34
|
ttl = redis.ttl(support.cache_key)
|
34
|
-
|
35
|
+
|
36
|
+
key_stat = if cached_content.present?
|
37
|
+
'has content'
|
38
|
+
elsif redis.exists(support.cache_key)
|
39
|
+
'exists but no content'
|
40
|
+
else
|
41
|
+
'not exists'
|
42
|
+
end
|
43
|
+
|
44
|
+
ttl_stat = if redis.exists(support.cache_key)
|
45
|
+
", ttl was: #{ttl} seconds, now set to: #{support.redis_expiration_seconds} seconds"
|
46
|
+
end
|
47
|
+
|
48
|
+
support.debug_log("Cache key: «#{support.cache_key}» (#{key_stat}#{ttl_stat})")
|
49
|
+
|
35
50
|
end
|
36
|
-
redis.expire(support.cache_key, support.redis_expiration_seconds)
|
37
51
|
|
38
|
-
|
52
|
+
redis.expire(support.cache_key, support.redis_expiration_seconds)
|
39
53
|
|
40
54
|
res = if cached_content
|
41
55
|
log_message = "Returned #{support.filename}.svelte from cache"
|