Project

redis_util

0.0
No commit activity in last 3 years
No release in over 3 years
An aggregation of redis utility code, including a factory for tracking connections
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

RedisUtil

An aggregation of redis utility code, including:

  • A factory which allows you to define redis connections in a config file, and keeps track of them for reconnecting in forks
  • Test helpers

Installation

Add this line to your application's Gemfile:

gem 'redis_util'

And then execute:

$ bundle

Or install it yourself as:

$ gem install redis_util

Then setup a config file in config/redis.yml that could look like:

common: &common
  host: localhost
  port: 6379
  thread_safe: true

development:
  resque:
    <<: *common
    db: 0
  redis_objects:
    <<: *common
    db: 1

test:
  resque:
    <<: *common
    db: 10
  redis_objects:
    <<: *common
    db: 11

If not running in rails, an additional step is needed to set the config_file and env:

RedisUtil::Factory.config_file = "#{root}/config/redis.yml"
RedisUtil::Factory.env = "development"

Usage

redis = RedisUtil::Factory.connect(:foo)
redis.keys('*')