0

Basically, I'm trying to parse the memcached file to .JSON, but am unforatenly not able to get the JSON to respond to any of the JSON parse commands (ie. only), to_json does work, but am unfamiliar with how memcached is reading. Essentially trying to setup a parse on "building", and a particular timestamp (for the labels), as well as values for a particular metric.

I am getting data to return both with memcached natively (I believe natively), and with to_json, but am having issues getting the data to be usable.

Can attach outputs on request.

Thanks!

Here is my memcached.rb file

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}"

OUTPUT FROM 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}}}"
Nomad
  • 250
  • 3
  • 11
  • 27
  • 1
    Why are you interpolating the return value of `cache.get` in a string? Also the `only:` option is just for when you are converting models to JSON - not an arbitrary string. – max Apr 30 '16 at 20:15
  • Primarily was just for familiarization with the cache commands, I have now removed them. Ah, that would explain a lot, for only:. Hmm, is it possible to interpret the strings from cache to get specific values in the same sense? Thanks, for the response. Fairly unfamiliar with how memcached and dashing work, but looking to get a memcached fed dashboard, hopefully! – Nomad Apr 30 '16 at 20:31

1 Answers1

1

While you can stuff JSON into memcached - it does not really make that much sense.

Instead you can stuff arrays and hash or any other data type and let memcached handle serializing and deserializing the object.

cache.set(:foo, { bar: 1, baz: 2 })
cache.get(:foo)
=> { bar: 1, baz: 2 }

If you want to filter the hash you can use ActiveSupport's Hash#except and Hash#slice.

cache.get(:foo).except(:bar)
=> {  baz: 2 }

The exception is of course if you are caching the parsed JSON representation of a resource if to avoid the cost of serialization. But in that case you would only really be treating it as a string anyways and not parsing it as that would defeat the whole point in the first place.


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
max
  • 96,212
  • 14
  • 104
  • 165
  • I have added my cache sample for visualization. I am able to get cache out and read through, but essentially what would be looking to do is interate through the output on certain "objects" I'll say for example: pick_shorts_dpmo, and to be able to call them in the job elsewhere in the application. – Nomad Apr 30 '16 at 20:55
  • 1
    Thats just a bunch of nested hashes as far as I can see - why do you think you should be using JSON? – max Apr 30 '16 at 20:56
  • 1
    I'm not completely sure what you are trying to but if you want to use for example a JSON file on disk you would read its contents and use JSON.parse on that. You would then store the resulting object (a hash or array or whatever it is) in memcached. – max Apr 30 '16 at 21:01
  • What I'm atttempting to do is essentially read a key from a memcached server we have on an ec2 instance host:port (in question), and from that key pull out particular "metrics" (pick_shorts_dpmo), along with that, their timestamp, top, bottom, avg, and those values. I believe I could still get this from using the hash as stated, but am unclear on how to retrieve, and/or to do this in the job themselves. I attempted to read from hash, but to avail: https://richonrails.com/articles/working-with-ruby-hashes – Nomad Apr 30 '16 at 21:04
  • 1
    Try just doing `cache.get('building-metric-12_hour')["pick_shorts_dpmo"]` - what your doing wrong is your taking what is actually a hash returned from memcached and casting it into a string and then JSON encoding it. – max Apr 30 '16 at 21:26
  • So, what I've done is... ruby_cache = JSON.parse(cache.get('CHA1-Pick-12_hour')) To un-nest the cache, and then to grab the specific metric I've done... p ruby_cache['pick_shorts_dpmo'].each { |timestamp| p timestamp } What I would like to do now, is call these in the JOBS piece on dashing and use timestamp as an axis, and then for the plots on the graph the integers from the output of top, bottom, avg. I have the visual pieces setup, but am now unsure how to get this has from the lib/ folder I have created over to the job, or best suited to do from the job. I can open a new question. – Nomad Apr 30 '16 at 21:38