Module: Harrods::RedisClient

Defined in:
lib/harrods/redis_client.rb

Class Method Summary collapse

Class Method Details

.average_log(request, ram, objects) ⇒ Object



8
9
10
11
12
# File 'lib/harrods/redis_client.rb', line 8

def average_log(request, ram, objects)
  current = recover_hash request
  current = process_averages current, ram, objects
  update_hash request, current
end

.clientObject



18
19
20
# File 'lib/harrods/redis_client.rb', line 18

def client
  @client ||= Redis::Namespace.new(Harrods.config.redis_namespace, redis: redis)
end

.get_average_for(request) ⇒ Object



14
15
16
# File 'lib/harrods/redis_client.rb', line 14

def get_average_for(request)
  return recover_hash request
end

.initialize_hash_from_redis(out) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/harrods/redis_client.rb', line 26

def initialize_hash_from_redis(out)
  out["ram"]        ||= 0
  out["objects"]    ||= 0
  out["iterations"] ||= 0
  out.each{ |k, v| out[k] = v.to_i }
  return out      
end

.redisObject



22
23
24
# File 'lib/harrods/redis_client.rb', line 22

def redis
  @redis ||= Redis.new(url: Harrods.config.redis_connection_string)
end