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: e4e1180e9510fa0b8592b0b17be5ae1f75348124861184022648f2ec6b96865d
4
- data.tar.gz: 737ff843db6d9fe9ae04d34fd24b214089368d2b34357ac0e64a14ff90c13d52
3
+ metadata.gz: 61a1a506e531e729e27433251f92fae2e24e73916f9004fafd75efb52b1a073e
4
+ data.tar.gz: d0cad407740e263bfc0f7b1dd58468734b4e4ddc00623257191c847144ddd1d1
5
5
  SHA512:
6
- metadata.gz: 769b3c284cdddd35fb86895a29a6ae3a7bce52f501cb689856c1d166892fd360a264eafe274f2cc41944ec57d1a044d25c2c3a1934149ce9e0d1afb972f4501a
7
- data.tar.gz: 2d067a4983fb063fc1e38a1a68e235050d405dad829bea0727ceed9a6d0a35752909d2ae2aba99177e73af21ef01e0cd848d51c30612838ea48fda5163c95c90
6
+ metadata.gz: 7d4404822d86e3e1eb612a937e2bf65883067e462779d5c4d469f6f456d87c97ad126d0ea9b2844ba4526880b82d44eeb12b1d40b988bb8c9dab3d9189ab219f
7
+ data.tar.gz: e86f2bb86f30a21165ed9422b7ef23eca36317ce1aedcc0e433792760cd3b7c6b10dc9d9bdd9c4ddc55f726fab5dd1c3f0d97f4817b93c75c14464ce1b8b38c3
@@ -42,11 +42,8 @@ module SvelteOnRails
42
42
 
43
43
  # DEFAULTS
44
44
 
45
- if @configs[:redis_cache_store]
46
- store = @configs[:redis_cache_store]
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
- { redis_cache_store: Rails.application.config.cache_store.second.deep_symbolize_keys }
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
@@ -352,6 +352,7 @@ module SvelteOnRails
352
352
  end
353
353
 
354
354
  def redis_expiration_seconds
355
+ # this accepts integer or ActiveSupport::Duration
355
356
  ex = @options[:cache_expires_in] || conf.configs[:cache_expires_in] || 3.days
356
357
  ex.to_i
357
358
  end
@@ -60,10 +60,7 @@ namespace :svelte_on_rails do
60
60
  next
61
61
  end
62
62
 
63
- extra = ENV["PATTERN"].to_s.strip
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, count: 500)
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| sort_by == "size" ? -e[:bytes] : e[:key] }
106
- shown = limit ? entries.first(limit) : entries
102
+ entries.sort_by! { |e| -e[:bytes] }
107
103
 
108
- key_w = [shown.map { |e| e[:key].length }.max, 3].max
109
- size_w = [shown.map { |e| human_bytes(e[:bytes]).length }.max, 4].max
110
- ttl_w = [shown.map { |e| ttl_str(e[:ttl]).length }.max, 3].max
111
- type_w = [shown.map { |e| e[:type].to_s.length }.max, 4].max
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
- shown.each do |e|
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: 3.days
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
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: 22.4.0
4
+ version: 22.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Sedlmair