No release in over a year
Redis caching for OpenWeatherClient
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.17
>= 10.0
>= 3.0

Runtime

>= 4.5.0
 Project Readme

OpenWeatherClient::Caching::Redis

Gem Version RSpec

Welcome to OpenWeatherClient::Caching::Redis. This gem provides the redis caching method for OpenWeatherClient.

Installation

Add this line to your application's Gemfile:

gem 'open_weather_client-caching-redis'

And then execute:

$ bundle

Or install it yourself as:

$ gem install open_weather_client-caching-redis

Usage

Configure OpenWeatherClient to use redis caching. The redis connection can be configured through rails credentials or by manually setting the parameters in configuration.

require 'open_weather_client-caching-redis/caching/redis'
require 'open_weather_client'

# OpenWeatherClient initializer
OpenWeatherClient.configure do |config|
  config.caching = OpenWeatherClient::Caching::Redis
  # Time in days until cached requests are expired, default: 7
  config.ttl = 14
  
  # redis connection configuration
  config.db = 0 # default
  config.host = 'localhost' # default
  config.password = '123456' # default: nil
  config.port = 6379 # default
end

Secure Configuration

# $ bin/rails credentials:edit
open_weather_client:
  appid: "<INSERT OPENWEATHERMAP API KEY HERE>"
  redis:
    db: 0
    host: 'localhost'
    password: '123456'
    port: 6379

After configuration of the credentials you can load the settings in your initializer with #load_from_rails_configuration. Raises KeyError if redis caching is used but credentials are not set.

# OpenWeatherClient initializer
OpenWeatherClient.configure do |config|
  config.caching = OpenWeatherClient::Caching::Redis
  config.load_from_rails_credentials
end

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/qurasoft/open_weather_client-caching-redis.

License

The gem is available as open source under the terms of the MIT License.