mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 07:18:06 +08:00
30990006a9
This reduces chances of errors where consumers of strings mutate inputs and reduces memory usage of the app. Test suite passes now, but there may be some stuff left, so we will run a few sites on a branch prior to merging
31 lines
628 B
Ruby
31 lines
628 B
Ruby
# frozen_string_literal: true
|
|
|
|
require File.expand_path("../../config/environment", __FILE__)
|
|
|
|
@redis = $redis.without_namespace
|
|
|
|
stats = {}
|
|
|
|
@redis.scan_each do |k|
|
|
type = @redis.type k
|
|
debug = @redis.debug :object, k
|
|
len = debug.split("serializedlength:")[1].to_i
|
|
|
|
case type
|
|
when "zset"
|
|
elems = @redis.zcard k
|
|
when "list"
|
|
elems = @redis.llen k
|
|
when "hash"
|
|
elems = @redis.hlen k
|
|
end
|
|
|
|
stats[k] = [len, type, elems]
|
|
end
|
|
|
|
puts "Top 100 keys"
|
|
stats.sort { |a, b| b[1][0] <=> a[1][0] }.first(50).each do |k, (len, type, elems)|
|
|
elems = " [#{elems}]" if elems
|
|
puts "#{k} #{type} #{len}#{elems}"
|
|
end
|