Skip to content
Browse files

Remove internal and use refactored redised gem

  • Loading branch information...
1 parent c21752a commit d0c020ce47071e2dbabd83a47de276dddff51a95 @quirkey quirkey committed Mar 19, 2012
Showing with 7 additions and 57 deletions.
  1. +3 −3 Gemfile
  2. +4 −1 Gemfile.lock
  3. +0 −53 lib/redised.rb
View
6 Gemfile
@@ -8,16 +8,16 @@ gem 'sinatra-contrib'
gem 'jim'
gem 'closure-compiler'
gem 'redis'
-gem 'redis-namespace'
+gem 'redised'
gem 'compass'
gem 'haml'
gem 'typhoeus'
gem 'yajl-ruby'
gem 'pony'
group :test do
- gem 'minitest'
- gem 'minitest-display'
+ gem 'minitest', :require => false
+ gem 'minitest-display', :require => false
end
group :development do
View
5 Gemfile.lock
@@ -73,6 +73,9 @@ GEM
redis (2.2.2)
redis-namespace (1.1.0)
redis (< 3.0.0)
+ redised (0.1.0)
+ redis (~> 2)
+ redis-namespace
ruby-debug-base19 (0.11.25)
columnize (>= 0.3.1)
linecache19 (>= 0.5.11)
@@ -141,7 +144,7 @@ DEPENDENCIES
rack (= 1.3.5)
rake
redis
- redis-namespace
+ redised
ruby-debug19
sinatra
sinatra-contrib
View
53 lib/redised.rb
@@ -1,53 +0,0 @@
-# Redised allows for the common patter of module access to redis, when included
-# a .redis and .redis= method are provided
-# Ganked from resque
-module Redised
-
- def self.redis_connection(params)
- @redis_connections ||= {}
- @redis_connections[params] ||= Redis.new(params)
- end
-
- def self.included(klass)
-
- klass.module_eval do
- # Accepts:
- # 1. A 'hostname:port' string
- # 2. A 'hostname:port:db' string (to select the Redis db)
- # 3. A 'hostname:port/namespace' string (to set the Redis namespace)
- # 4. A redis URL string 'redis://host:port'
- # 5. An instance of `Redis`, `Redis::Client`, `Redis::DistRedis`,
- # or `Redis::Namespace`.
- def self.redis=(server)
- if server.respond_to? :split
-
- if server =~ /redis\:\/\//
- conn = ::Redised.redis_connection(:url => server)
- else
- server, namespace = server.split('/', 2)
- host, port, db = server.split(':')
- conn = ::Redised.redis_connection(:host => host, :port => port,
- :thread_safe => true, :db => db)
- end
- namespace ||= :resque
-
- @redis = Redis::Namespace.new(namespace, :redis => conn)
- elsif server.respond_to? :namespace=
- @redis = server
- else
- @redis = Redis::Namespace.new(:resque, :redis => server)
- end
- end
-
- # Returns the current Redis connection. If none has been created, will
- # create a new one.
- def self.redis
- return @redis if @redis
- rescue NoMethodError => e
- raise("There was a problem setting up your redis for redis_namespace #{redis_namespace}: #{e}")
- end
- end
-
- end
-
-end

0 comments on commit d0c020c

Please sign in to comment.
Something went wrong with that request. Please try again.