class RedisWebManager::Data
Constants
- BASE
Public Instance Methods
flush()
click to toggle source
# File lib/redis_web_manager/data.rb, line 17 def flush data.map { |key| redis.del(key) } end
keys()
click to toggle source
# File lib/redis_web_manager/data.rb, line 7 def keys data.map { |key| JSON.parse(redis.get(key), symbolize_names: true) } end
perform()
click to toggle source
# File lib/redis_web_manager/data.rb, line 11 def perform now = Time.now.to_i seconds = (now + lifespan.to_i) - now redis.setex("#{BASE}_#{instance}_#{now}", seconds, serialize.to_json) end
Private Instance Methods
client()
click to toggle source
# File lib/redis_web_manager/data.rb, line 51 def client { connected_clients: stats[:connected_clients], blocked_clients: stats[:blocked_clients] } end
cpu()
click to toggle source
# File lib/redis_web_manager/data.rb, line 58 def cpu { used_cpu_sys: stats[:used_cpu_sys], used_cpu_user: stats[:used_cpu_user], used_cpu_sys_children: stats[:used_cpu_sys_children], used_cpu_user_children: stats[:used_cpu_user_children] } end
data()
click to toggle source
# File lib/redis_web_manager/data.rb, line 23 def data @data ||= redis.scan_each(match: "#{BASE}_#{instance}_*").to_a end
lifespan()
click to toggle source
# File lib/redis_web_manager/data.rb, line 27 def lifespan @lifespan ||= RedisWebManager.lifespan end
memory()
click to toggle source
# File lib/redis_web_manager/data.rb, line 40 def memory { used_memory: stats[:used_memory], used_memory_rss: stats[:used_memory_rss], used_memory_peak: stats[:used_memory_peak], used_memory_overhead: stats[:used_memory_overhead], used_memory_startup: stats[:used_memory_startup], used_memory_dataset: stats[:used_memory_dataset] } end
serialize()
click to toggle source
# File lib/redis_web_manager/data.rb, line 31 def serialize { date: Time.now, memory: memory, client: client, cpu: cpu } end
stats()
click to toggle source
# File lib/redis_web_manager/data.rb, line 67 def stats @stats ||= redis.info.symbolize_keys end