Sha256: f7bcae86c7ed044caf39655d7006a4844d87c34c526301d1e743a4a544264796

Contents?: true

Size: 366 Bytes

Versions: 22

Compression:

Stored size: 366 Bytes

Contents

require 'redis'

class Harmony::Service::Utils::Storage
  
  def get(key)
    json = redis.get(key)
    JSON.parse(json) if json
  end
  
  def set(key, value)
    redis.set(key, value.to_json)
  end
  
  def clear(key)
    redis.del(key)
  end
  
  private
  def redis
    @redis ||= Redis.new(url: redis_url)
  end
  
  def redis_url
    ENV['redis_url']
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
harmony-service-0.8.3 lib/harmony/service/utils/storage.rb
harmony-service-0.8.2 lib/harmony/service/utils/storage.rb
harmony-service-0.8.1 lib/harmony/service/utils/storage.rb
harmony-service-0.8.0 lib/harmony/service/utils/storage.rb
harmony-service-0.7.2 lib/harmony/service/utils/storage.rb
harmony-service-0.7.1 lib/harmony/service/utils/storage.rb
harmony-service-0.7.0 lib/harmony/service/utils/storage.rb
harmony-service-0.6.0 lib/harmony/service/utils/storage.rb
harmony-service-0.5.8 lib/harmony/service/utils/storage.rb
harmony-service-0.5.7 lib/harmony/service/utils/storage.rb
harmony-service-0.5.6 lib/harmony/service/utils/storage.rb
harmony-service-0.5.5 lib/harmony/service/utils/storage.rb
harmony-service-0.5.4 lib/harmony/service/utils/storage.rb
harmony-service-0.5.3 lib/harmony/service/utils/storage.rb
harmony-service-0.5.2 lib/harmony/service/utils/storage.rb
harmony-service-0.5.1 lib/harmony/service/utils/storage.rb
harmony-service-0.5.0 lib/harmony/service/utils/storage.rb
harmony-service-0.4.4 lib/harmony/service/utils/storage.rb
harmony-service-0.4.3 lib/harmony/service/utils/storage.rb
harmony-service-0.4.2 lib/harmony/service/utils/storage.rb