2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-07-10 06:59:44 +08:00
|
|
|
require File.expand_path("../../config/environment", __FILE__)
|
|
|
|
|
2019-12-03 17:05:53 +08:00
|
|
|
@redis = Discourse.redis.without_namespace
|
2015-07-10 06:59:44 +08:00
|
|
|
|
|
|
|
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"
|
2017-07-28 09:20:09 +08:00
|
|
|
stats.sort { |a, b| b[1][0] <=> a[1][0] }.first(50).each do |k, (len, type, elems)|
|
2015-07-10 06:59:44 +08:00
|
|
|
elems = " [#{elems}]" if elems
|
|
|
|
puts "#{k} #{type} #{len}#{elems}"
|
|
|
|
end
|