Sha256: 4a68c18601f0ba9e8f5d74a5d369204ce89b013cfc1df73c51e33b148d6c9415
Contents?: true
Size: 751 Bytes
Versions: 1
Compression:
Stored size: 751 Bytes
Contents
require 'redis' module Skalera module Services class Redis SERVICE_NAME = 'redis' def self.instance(database = 0) redis_config = Diplomat::Service.get(SERVICE_NAME) redis = ::Redis.new(url: url(password, redis_config.Address, redis_config.ServicePort, database)) at_exit { redis.quit } redis rescue Diplomat::KeyNotFound STDERR.puts "ERROR: service not found: #{SERVICE_NAME}" end def self.url(password, host, port, database) pwd = password ? "#{password}:" : '' "redis://#{pwd}#{host}:#{port}/#{database}" end def self.password Diplomat.get('redis/password') rescue Diplomat::KeyNotFound nil end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
skalera-services-0.2.4 | lib/skalera/services/redis.rb |