svelte-on-rails 22.5.5 → 22.5.6
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/view_helpers.rb +1 -1
- data/lib/tasks/cache_tasks.rake +59 -24
- 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: ab6d571ef0c95edbc34868a44322a5fd65ce530ec4bf9d25abae20bb3f07cb6d
|
|
4
|
+
data.tar.gz: 875903772b806d6be74e66057cfb75c14d12e127a7024ab240be4d8e9b52f8c6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0bf76f5cc03cd13af95609c0a3e5d1ae7c5d6e9b899cad7f0fea2da9636a12cd8e015bf6e8f7fb5475d55a82f33ad3362123ee57c81e30b9cbecfb2f669586e5
|
|
7
|
+
data.tar.gz: 585f3cefa671842756b103dbafded674e47c217db31954044e42731dbe1648a293210b0b156ef8de842a74c24891a929c871121fd3d3da9e1d4b06d9032b0312
|
|
@@ -45,9 +45,9 @@ module SvelteOnRails
|
|
|
45
45
|
support.render_cached(self) do
|
|
46
46
|
rnd = support.render_svelte(@current_template)
|
|
47
47
|
if rnd[:success]
|
|
48
|
+
support.log_completed("returned from cache, with uncached props#{', (Fallback!)' if rnd[:fallback]}")
|
|
48
49
|
concat(rnd[:head].html_safe)
|
|
49
50
|
concat(rnd[:html].html_safe)
|
|
50
|
-
support.log_completed("returned from cache, with uncached props#{', (Fallback!)' if rnd[:fallback]}")
|
|
51
51
|
elsif config.configs[:ssr_error_tag]
|
|
52
52
|
sor_error_tag(support, wrapper_html, component_props, 'server-side-svelte-render-error', 'SVELTE RENDER FAILED')
|
|
53
53
|
else
|
data/lib/tasks/cache_tasks.rake
CHANGED
|
@@ -51,13 +51,69 @@ namespace :svelte_on_rails do
|
|
|
51
51
|
|
|
52
52
|
desc "Show all svelte-on-rails Redis keys with their memory footprint (scoped to redis_namespace). Env: LIMIT=n, SORT=size|key, PATTERN=extra-glob"
|
|
53
53
|
task show: :environment do
|
|
54
|
+
|
|
55
|
+
_entries = entries
|
|
56
|
+
|
|
57
|
+
_entries.sort_by! { |e| -e[:bytes] }
|
|
58
|
+
|
|
59
|
+
key_w = [_entries.map { |e| e[:key].length }.max, 3].max
|
|
60
|
+
size_w = [_entries.map { |e| human_bytes(e[:bytes]).length }.max, 4].max
|
|
61
|
+
ttl_w = [_entries.map { |e| ttl_str(e[:ttl]).length }.max, 3].max
|
|
62
|
+
type_w = [_entries.map { |e| e[:type].to_s.length }.max, 4].max
|
|
63
|
+
|
|
64
|
+
header = format("%-#{key_w}s %#{size_w}s %#{ttl_w}s %-#{type_w}s", "KEY", "SIZE", "TTL", "TYPE")
|
|
65
|
+
puts header
|
|
66
|
+
puts "-" * header.length
|
|
67
|
+
|
|
68
|
+
_entries.each do |e|
|
|
69
|
+
puts format(
|
|
70
|
+
"%-#{key_w}s %#{size_w}s %#{ttl_w}s %-#{type_w}s",
|
|
71
|
+
e[:key], human_bytes(e[:bytes]), ttl_str(e[:ttl]), e[:type]
|
|
72
|
+
)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
total_bytes = _entries.sum { |e| e[:bytes] }
|
|
76
|
+
puts "-" * header.length
|
|
77
|
+
puts "Total: #{_entries.size} key(s), #{human_bytes(total_bytes)} in RAM"
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
desc "Show contents of cached keys"
|
|
81
|
+
task show_contents: :environment do
|
|
82
|
+
|
|
83
|
+
entries.each do |e|
|
|
84
|
+
puts '='*120
|
|
85
|
+
puts "#{e[:key]} (#{human_bytes(e[:bytes])})"
|
|
86
|
+
puts '-'*120
|
|
87
|
+
puts SvelteOnRails::Configuration.instance.redis_instance.get(e[:key])
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
desc "Show only the svelte part (wrapping div stripped away) of cached keys"
|
|
93
|
+
task show_svelte: :environment do
|
|
94
|
+
|
|
95
|
+
entries.each do |e|
|
|
96
|
+
|
|
97
|
+
ht = SvelteOnRails::Configuration.instance.redis_instance.get(e[:key])
|
|
98
|
+
nok = Nokogiri::HTML(ht)
|
|
99
|
+
|
|
100
|
+
puts '='*120
|
|
101
|
+
puts "#{e[:key]} (#{human_bytes(e[:bytes])})"
|
|
102
|
+
puts '-'*120
|
|
103
|
+
puts nok.at_css('.svelte-component')&.inner_html
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def entries
|
|
54
110
|
conf = SvelteOnRails::Configuration.instance
|
|
55
111
|
redis = conf.redis_instance
|
|
56
112
|
namespace = conf.redis_namespace
|
|
57
113
|
|
|
58
114
|
unless redis
|
|
59
115
|
warn "svelte_on_rails:show_cache — no redis_instance configured, nothing to show."
|
|
60
|
-
|
|
116
|
+
return []
|
|
61
117
|
end
|
|
62
118
|
|
|
63
119
|
pattern = "#{namespace}*"
|
|
@@ -96,30 +152,9 @@ namespace :svelte_on_rails do
|
|
|
96
152
|
|
|
97
153
|
if entries.empty?
|
|
98
154
|
puts "No keys found under «#{pattern}»."
|
|
99
|
-
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
entries.sort_by! { |e| -e[:bytes] }
|
|
103
|
-
|
|
104
|
-
key_w = [entries.map { |e| e[:key].length }.max, 3].max
|
|
105
|
-
size_w = [entries.map { |e| human_bytes(e[:bytes]).length }.max, 4].max
|
|
106
|
-
ttl_w = [entries.map { |e| ttl_str(e[:ttl]).length }.max, 3].max
|
|
107
|
-
type_w = [entries.map { |e| e[:type].to_s.length }.max, 4].max
|
|
108
|
-
|
|
109
|
-
header = format("%-#{key_w}s %#{size_w}s %#{ttl_w}s %-#{type_w}s", "KEY", "SIZE", "TTL", "TYPE")
|
|
110
|
-
puts header
|
|
111
|
-
puts "-" * header.length
|
|
112
|
-
|
|
113
|
-
entries.each do |e|
|
|
114
|
-
puts format(
|
|
115
|
-
"%-#{key_w}s %#{size_w}s %#{ttl_w}s %-#{type_w}s",
|
|
116
|
-
e[:key], human_bytes(e[:bytes]), ttl_str(e[:ttl]), e[:type]
|
|
117
|
-
)
|
|
155
|
+
return []
|
|
118
156
|
end
|
|
119
|
-
|
|
120
|
-
total_bytes = entries.sum { |e| e[:bytes] }
|
|
121
|
-
puts "-" * header.length
|
|
122
|
-
puts "Total: #{entries.size} key(s), #{human_bytes(total_bytes)} in RAM"
|
|
157
|
+
entries
|
|
123
158
|
end
|
|
124
159
|
end
|
|
125
160
|
end
|