class RoutingNumber::RedisStore

Constants

LOADED_KEY
LOADING_KEY
STORAGE_KEY

Public Class Methods

new(*args) click to toggle source
Calls superclass method RoutingNumber::StoreBase::new
# File lib/bank_routing/storage/redis.rb, line 11
def initialize(*args)
  super(*args)
  require 'redis'
end

Public Instance Methods

connect() click to toggle source
# File lib/bank_routing/storage/redis.rb, line 54
def connect
  log.info "Connecting to Redis."
  log.debug "Connection settings: #{options.inspect}"
  Redis.new(options)
end
done_loading!() click to toggle source
# File lib/bank_routing/storage/redis.rb, line 33
def done_loading!
  store.del(LOADING_KEY)
  loaded!
end
get(num) click to toggle source
# File lib/bank_routing/storage/redis.rb, line 42
def get(num)
  if cnt = store.hget(STORAGE_KEY,num.to_s)
    Yajl::Parser.new(symbolize_keys: true).parse(cnt)
  else
    nil
  end
end
loaded!() click to toggle source
# File lib/bank_routing/storage/redis.rb, line 20
def loaded!
  store.set(LOADED_KEY,"yes")
  store.expire(LOADED_KEY,60*60*24*7)
end
loaded?() click to toggle source
# File lib/bank_routing/storage/redis.rb, line 16
def loaded?
  store.exists(LOADED_KEY)
end
loading!() click to toggle source
# File lib/bank_routing/storage/redis.rb, line 25
def loading!
  store.setnx(LOADING_KEY,"yup")
end
loading?() click to toggle source
# File lib/bank_routing/storage/redis.rb, line 29
def loading?
  loading!
end
reconnect!() click to toggle source
# File lib/bank_routing/storage/redis.rb, line 60
def reconnect!
  @store = nil
  store
end
save(num,obj) click to toggle source
# File lib/bank_routing/storage/redis.rb, line 38
def save(num,obj)
  store.hset(STORAGE_KEY,num.to_s,Yajl::Encoder.encode(obj))
end
shutdown!() click to toggle source
# File lib/bank_routing/storage/redis.rb, line 65
def shutdown!
  @store = nil
end
store() click to toggle source
# File lib/bank_routing/storage/redis.rb, line 50
def store
  @store ||= connect
end