基本上,我正在尝试将memcached文件解析为.JSON,但不幸的是,我无法让JSON响应任何JSON parse命令(即,.唯一),to_json确实可以工作,但我不熟悉memcached是如何读取的。本质上是尝试在“构建”上设置解析,以及特定的时间戳(标签),以及特定指标的值。
我用本地的memcached (我相信是本地的)和to_json都可以返回数据,但是我在获取可用的数据时遇到了问题。
可以根据请求附加输出。
谢谢!
这是我的memcached.rb文件
require 'memcache'
require 'active_support/cache'
require 'json'
options = {
}
servers = [
'host:port' <- Hidden for obvious reasons.
]
cache = MemCache.new(servers)
random_key = (0...8).map { (65 + rand(26)).chr }.join
random_value = (0...8).map { (65 + rand(26)).chr }.join
cache_get = "#{cache.get('building-metric-12_hour')}".to_json
p "Checking random key (#{random_key}), #{random_key} should be nil"
p "Inserting random value (#{random_value}) into key. #{cache.set(random_key, random_value)}"
p "Getting value back out: #{random_key}"
p "CACHE_GET: #{cache_get}"CACHE_GET的输出:
/*
* 提示:该行代码过长,系统自动注释不进行高亮。一键复制会移除系统注释
* "CACHE_GET: {\"building\":\"123\",\"process\":\"Pick\",\"interval\":\"12_hour\",\"timestamp\":\"2016-04-29 19:32:49 UTC\",\"pick_shorts_dpmo\":{\"2016-04-29 07:45:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 08:00:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 08:15:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 08:30:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 08:45:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 09:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 09:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 09:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 09:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 10:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 10:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 10:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 10:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 11:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 11:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 11:30:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 11:45:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 12:00:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 12:15:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 12:30:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 12:45:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 13:00:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 13:15:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 13:30:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 13:45:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 14:00:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 14:15:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 14:30:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 14:45:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 15:00:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 15:15:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 15:30:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 15:45:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 16:00:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 16:15:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 16:30:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 16:45:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 17:00:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 17:15:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 17:30:00 UTC\":{\"top_10\":202532,\"average\":12705,\"bottom_10\":0},\"2016-04-29 17:45:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 18:00:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 18:15:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 18:30:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 18:45:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 19:00:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 19:15:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 19:30:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0}},\"pick_damages_dpmo\":{\"2016-04-29 07:45:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 08:00:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 08:15:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 08:30:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 08:45:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 09:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 09:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 09:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 09:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 10:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 10:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 10:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 10:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 11:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 11:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 11:30:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 11:45:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 12:00:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 12:15:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 12:30:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 12:45:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 13:00:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 13:15:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 13:30:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 13:45:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 14:00:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 14:15:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 14:30:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 14:45:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 15:00:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 15:15:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 15:30:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 15:45:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 16:00:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 16:15:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 16:30:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 16:45:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 17:00:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 17:15:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 17:30:00 UTC\":{\"top_10\":108434,\"average\":4764,\"bottom_10\":0},\"2016-04-29 17:45:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 18:00:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 18:15:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 18:30:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 18:45:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 19:00:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 19:15:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 19:30:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0}},\"pick_rejects_dpmo\":{\"2016-04-29 07:45:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 08:00:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 08:15:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 08:30:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 08:45:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 09:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 09:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 09:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 09:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 10:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 10:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 10:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 10:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 11:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 11:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 11:30:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 11:45:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 12:00:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 12:15:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 12:30:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 12:45:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 13:00:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 13:15:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 13:30:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 13:45:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 14:00:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 14:15:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 14:30:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 14:45:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 15:00:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 15:15:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 15:30:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 15:45:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 16:00:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 16:15:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 16:30:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 16:45:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 17:00:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 17:15:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 17:30:00 UTC\":{\"top_10\":280488,\"average\":12176,\"bottom_10\":0},\"2016-04-29 17:45:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 18:00:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 18:15:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 18:30:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 18:45:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 19:00:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 19:15:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0},\"2016-04-29 19:30:00 UTC\":{\"top_10\":0,\"average\":0,\"bottom_10\":0}},\"pick_audits_from_trans_dpmo\":{\"2016-04-29 07:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 08:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 08:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 08:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 08:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 09:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 09:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 09:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 09:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 10:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 10:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 10:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 10:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 11:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 11:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 11:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 11:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 12:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 12:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 12:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 12:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 13:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 13:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 13:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 13:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 14:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 14:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 14:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 14:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 15:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 15:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 15:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 15:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 16:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 16:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 16:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 16:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 17:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 17:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 17:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 17:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 18:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 18:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 18:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 18:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 19:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 19:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 19:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null}},\"pick_short_no_scan_dpmo\":{\"2016-04-29 07:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 08:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 08:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 08:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 08:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 09:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 09:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 09:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 09:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 10:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 10:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 10:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 10:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 11:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 11:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 11:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 11:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 12:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 12:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 12:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 12:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 13:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 13:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 13:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 13:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 14:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 14:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 14:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 14:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 15:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 15:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 15:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 15:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 16:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 16:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 16:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 16:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 17:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 17:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 17:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 17:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 18:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 18:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 18:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 18:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 19:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 19:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 19:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null}},\"pick_wrong_asin_dpmo\":{\"2016-04-29 07:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 08:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 08:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 08:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 08:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 09:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 09:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 09:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 09:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 10:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 10:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 10:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 10:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 11:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 11:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 11:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 11:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 12:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 12:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 12:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 12:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 13:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 13:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 13:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 13:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 14:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 14:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 14:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 14:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 15:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 15:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 15:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 15:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 16:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 16:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 16:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 16:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 17:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 17:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 17:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 17:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 18:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 18:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 18:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 18:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 19:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 19:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 19:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null}},\"pick_unscannables_dpmo\":{\"2016-04-29 07:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 08:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 08:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 08:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 08:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 09:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 09:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 09:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 09:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 10:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 10:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 10:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 10:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 11:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 11:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 11:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 11:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 12:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 12:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 12:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 12:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 13:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 13:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 13:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 13:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 14:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 14:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 14:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 14:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 15:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 15:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 15:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 15:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 16:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 16:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 16:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 16:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 17:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 17:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 17:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 17:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 18:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 18:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 18:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 18:45:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 19:00:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 19:15:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null},\"2016-04-29 19:30:00 UTC\":{\"top_10\":null,\"average\":null,\"bottom_10\":null}}}"
*/发布于 2016-05-01 04:48:34
虽然您可以将JSON填充到memcached中-但这并没有多大意义。
相反,您可以填充数组和散列或任何其他数据类型,并让memcached处理对象的序列化和反序列化。
cache.set(:foo, { bar: 1, baz: 2 })
cache.get(:foo)
=> { bar: 1, baz: 2 }如果你想过滤散列,你可以使用ActiveSupport's Hash#except and Hash#slice。
cache.get(:foo).except(:bar)
=> { baz: 2 }当然,如果为了避免序列化的开销而缓存资源的解析JSON表示,则会有例外。但在这种情况下,您实际上只是将其视为一个字符串,而不是解析它,因为这将在一开始就破坏了整个要点。
require 'memcache'
require 'active_support'
servers = [
'host:port' # <- Hidden for obvious reasons.
]
cache = MemCache.new(servers)
random_key = (0...8).map { (65 + rand(26)).chr }.join
random_value = (0...8).map { (65 + rand(26)).chr }.join
data = cache.get('building-metric-12_hour')
p data.inspect
p data.keys.inspect
# to traverse the hash you would for example do:
p data["pick_shorts_dpmo"].inspecthttps://stackoverflow.com/questions/36959472
复制相似问题