svelte-on-rails 22.4.0 → 22.4.1
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 61a1a506e531e729e27433251f92fae2e24e73916f9004fafd75efb52b1a073e
|
|
4
|
+
data.tar.gz: d0cad407740e263bfc0f7b1dd58468734b4e4ddc00623257191c847144ddd1d1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7d4404822d86e3e1eb612a937e2bf65883067e462779d5c4d469f6f456d87c97ad126d0ea9b2844ba4526880b82d44eeb12b1d40b988bb8c9dab3d9189ab219f
|
|
7
|
+
data.tar.gz: e86f2bb86f30a21165ed9422b7ef23eca36317ce1aedcc0e433792760cd3b7c6b10dc9d9bdd9c4ddc55f726fab5dd1c3f0d97f4817b93c75c14464ce1b8b38c3
|
|
@@ -42,11 +42,8 @@ module SvelteOnRails
|
|
|
42
42
|
|
|
43
43
|
# DEFAULTS
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
@redis_namespace = store[:namespace]
|
|
48
|
-
end
|
|
49
|
-
@redis_namespace ||= "#{app_name}:svelte-on-rails:#{Rails.env rescue 'no-env'}"
|
|
45
|
+
rd = @configs[:redis_cache_store] && @configs[:redis_cache_store][:namespace]
|
|
46
|
+
@redis_namespace ||= "#{rd || app_name}:svelte-on-rails:#{Rails.env rescue 'no-env'}"
|
|
50
47
|
@configs[:skip_ssr_header] ||= 'X-Turbo-Request-ID'
|
|
51
48
|
if defined? Redis
|
|
52
49
|
@redis_instance = Redis.new(url: redis_cache_store[:url])
|
|
@@ -182,7 +179,8 @@ module SvelteOnRails
|
|
|
182
179
|
|
|
183
180
|
def redis_cache_store_configs
|
|
184
181
|
if defined?(Rails.application) && Rails.application.config.cache_store.is_a?(Array) && Rails.application.config.cache_store.first == :redis_cache_store
|
|
185
|
-
|
|
182
|
+
rc = Rails.application.config.cache_store.second.deep_symbolize_keys
|
|
183
|
+
{ redis_cache_store: rc.slice(:url, :namespace) }
|
|
186
184
|
else
|
|
187
185
|
{}
|
|
188
186
|
end
|
data/lib/tasks/cache_tasks.rake
CHANGED
|
@@ -60,10 +60,7 @@ namespace :svelte_on_rails do
|
|
|
60
60
|
next
|
|
61
61
|
end
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
pattern = extra.empty? ? "#{namespace}:*" : "#{namespace}:*#{extra}*"
|
|
65
|
-
limit = ENV["LIMIT"].to_s =~ /\A\d+\z/ ? ENV["LIMIT"].to_i : nil
|
|
66
|
-
sort_by = %w[size key].include?(ENV["SORT"]) ? ENV["SORT"] : "size"
|
|
63
|
+
pattern = "#{namespace}:*"
|
|
67
64
|
|
|
68
65
|
puts "Scanning Redis for keys matching «#{pattern}» ..."
|
|
69
66
|
|
|
@@ -71,7 +68,7 @@ namespace :svelte_on_rails do
|
|
|
71
68
|
cursor = "0"
|
|
72
69
|
|
|
73
70
|
loop do
|
|
74
|
-
cursor, keys = redis.scan(cursor, match: pattern
|
|
71
|
+
cursor, keys = redis.scan(cursor, match: pattern)
|
|
75
72
|
|
|
76
73
|
if keys.any?
|
|
77
74
|
# Pipeline MEMORY USAGE / TTL / TYPE for the whole batch.
|
|
@@ -102,19 +99,18 @@ namespace :svelte_on_rails do
|
|
|
102
99
|
next
|
|
103
100
|
end
|
|
104
101
|
|
|
105
|
-
entries.sort_by! { |e|
|
|
106
|
-
shown = limit ? entries.first(limit) : entries
|
|
102
|
+
entries.sort_by! { |e| -e[:bytes] }
|
|
107
103
|
|
|
108
|
-
key_w = [
|
|
109
|
-
size_w = [
|
|
110
|
-
ttl_w = [
|
|
111
|
-
type_w = [
|
|
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
|
|
112
108
|
|
|
113
109
|
header = format("%-#{key_w}s %#{size_w}s %#{ttl_w}s %-#{type_w}s", "KEY", "SIZE", "TTL", "TYPE")
|
|
114
110
|
puts header
|
|
115
111
|
puts "-" * header.length
|
|
116
112
|
|
|
117
|
-
|
|
113
|
+
entries.each do |e|
|
|
118
114
|
puts format(
|
|
119
115
|
"%-#{key_w}s %#{size_w}s %#{ttl_w}s %-#{type_w}s",
|
|
120
116
|
e[:key], human_bytes(e[:bytes]), ttl_str(e[:ttl]), e[:type]
|
|
@@ -123,8 +119,7 @@ namespace :svelte_on_rails do
|
|
|
123
119
|
|
|
124
120
|
total_bytes = entries.sum { |e| e[:bytes] }
|
|
125
121
|
puts "-" * header.length
|
|
126
|
-
puts "Total: #{entries.size} key(s), #{human_bytes(total_bytes)} in RAM"
|
|
127
|
-
"#{limit && entries.size > limit ? " (showing top #{limit} by #{sort_by})" : ""}"
|
|
122
|
+
puts "Total: #{entries.size} key(s), #{human_bytes(total_bytes)} in RAM"
|
|
128
123
|
end
|
|
129
124
|
end
|
|
130
125
|
end
|
|
@@ -55,8 +55,9 @@ use_caching: false
|
|
|
55
55
|
# this is the default for the #svelte view-helper.
|
|
56
56
|
# When set to true, the redis gem is required.
|
|
57
57
|
|
|
58
|
-
cache_expires_in:
|
|
58
|
+
#cache_expires_in: 4.days
|
|
59
59
|
# ttl for cache keys
|
|
60
|
+
# can be overridden by view-helper options
|
|
60
61
|
# default: 3.days
|
|
61
62
|
|
|
62
63
|
debug: true
|