2016-04-30 18 views
0

基本上,我試圖將memcached文件解析爲.JSON,但是我無法得到JSON響應任何JSON解析命令(即,僅), to_json確實有用,但我不熟悉memcached是如何讀取的。本質上試圖設置「構建」的解析,以及特定時間戳(對於標籤)以及特定度量的值。從Memcached讀到Dashing(Sinatra)

我正在獲取數據以本機方式(本機相信)和to_json同時返回memcached,但遇到問題使數據可用。

可根據要求附加輸出。

謝謝!

這裏是我的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}}}" 
+1

你爲什麼要插在一個字符串'cache.get'的返回值?此外,'only:'選項僅用於將模型轉換爲JSON時使用 - 不是任意字符串。 – max

+0

主要是爲了熟悉緩存命令,現在我已經將它們刪除了。 啊,這將解釋很多,只有:。嗯,是否有可能從緩存中解釋字符串以獲得具有相同意義的特定值? 感謝您的回覆。相當不熟悉memcached和瀟灑的工作方式,但希望獲得memcached fed控制面板,希望! – Spartacus38

回答

1

雖然可以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"].inspect 
+0

我已經添加了我的緩存樣本以進行可視化。我能夠緩存並通讀,但實質上,我們要做的是在某些「對象」上輸出結果,例如pick_shorts_dpmo,並且能夠在其他地方的工作中調用它們應用程序。 – Spartacus38

+1

就我所見,這只是一堆嵌套散列 - 你爲什麼認爲你應該使用JSON? – max

+1

我不完全確定你正在嘗試的是什麼,但是如果你想在磁盤上使用例如JSON文件,你可以閱讀它的內容並在其上使用JSON.parse。然後,您將在memcached中存儲結果對象(散列或數組或其它)。 – max