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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c6b58bda075eda9a5f99024e0903349bded01f4e383f241c08108c73f012b124
4
- data.tar.gz: d252c973002ce1bcc9359869a77c0800c2a6b94c813563019432a1490180cbd7
3
+ metadata.gz: a04f321576291cd2c8663dd72fb181438a64e678151a48cce151fab567cb63be
4
+ data.tar.gz: 896d0ca8348e9ef37cfd5ba61fef9ea51a9c315e14afb0fd6a4f2c6472737ae1
5
5
  SHA512:
6
- metadata.gz: 4299f254dbe525ad6a4725c75f5db2254883776a3479e137adfbefa4dbca4bd39421963458e73eb476c355c820a164e6ee28df1de9ae45443896f6bcc2c89ec1
7
- data.tar.gz: fcbf455e8ab2b244b3dad582f01d822ed6d76f5bafdadc2fd6bc75eec08eaaa4aec456f9ea69afc9abc0b691f4628eab1049748a29a8b549ebeb07340f61c8ab
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 { |k| k.is_a?(ActiveRecord::Base) ? "#{k.class.name}#{k.id}" : k.to_s }.join('-')
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
- support.debug_log("Cache key: «#{support.cache_key}» (ttl was: #{ttl} seconds, now set to: #{support.redis_expiration_seconds} seconds)")
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
- cached_content = redis.get(support.cache_key)
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"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: svelte-on-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Sedlmair