Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Redis::Objects.redis and Redis::Objects.redis=(conn) implies that the ca... #59

Closed
wants to merge 1 commit into from

3 participants

@monde

...nonical place to set a redis connection global to the library is there. See lines 53 and 54

https://github.com/nateware/redis-objects/blob/master/lib/redis/objects.rb#L53

https://github.com/nateware/redis-objects/blob/master/lib/redis/objects.rb#L54

We had two separated redis connections (resque, and redis objects) in http://www.hark.com/, and when we added a third separated connection to different redis server the redis objects library inappropriately attached itself there via $redis || Redis.current in Redis::BaseObject#initializer

@monde monde Redis::Objects.redis and Redis::Objects.redis=(conn) implies that the…
… canonical place to set a redis connection global to the library is there. See lines 53 and 54


https://github.com/nateware/redis-objects/blob/master/lib/redis/objects.rb#L53

https://github.com/nateware/redis-objects/blob/master/lib/redis/objects.rb#L54

We had two separated redis connections (resque, and redis objects) in http://www.hark.com/, and when we added a third separated connection to different redis server the redis objects library inappropriately attached itself there via $redis || Redis.current in Redis::BaseObject#initializer
e62e165
@nateware
Owner

This is a good idea but I'll need to review a bit more when I have a minute. Specifically, when the libraries are used separately (eg Redis::List) then Redis::Objects is not defined.

@myronmarston

FWIW, I just started using redis-objects, and I'm likely to have needs soon to allow the redis connection to be set at the instance level, so that different instances of classes that mixin Redis::Objects can be backed by different redis servers.

Not sure if that should play into this discussion or not, but figured I'd mention it :).

@monde

The current behavior probably shouldn't be changed from what the community is saying. Perhaps the README should be clear that the developer needs to make a decision about their connection strategy (global or instance). That the implied global connection is actually greedy unless configured properly such as the way my diff implements the default global configuration.

@nateware
Owner

This is being addressed in master currently; if you're still interested, please do try it out:

gem 'redis-objects', :git => 'git://github.com/nateware/redis-objects.git'

Cheers,
Nate

@nateware
Owner

this fix has been pushed to rubygems in v0.7.0

@nateware nateware closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 24, 2012
  1. @monde

    Redis::Objects.redis and Redis::Objects.redis=(conn) implies that the…

    monde authored
    … canonical place to set a redis connection global to the library is there. See lines 53 and 54
    
    
    https://github.com/nateware/redis-objects/blob/master/lib/redis/objects.rb#L53
    
    https://github.com/nateware/redis-objects/blob/master/lib/redis/objects.rb#L54
    
    We had two separated redis connections (resque, and redis objects) in http://www.hark.com/, and when we added a third separated connection to different redis server the redis objects library inappropriately attached itself there via $redis || Redis.current in Redis::BaseObject#initializer
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  lib/redis/base_object.rb
View
2  lib/redis/base_object.rb
@@ -4,7 +4,7 @@ class BaseObject
def initialize(key, *args)
@key = key.is_a?(Array) ? key.flatten.join(':') : key
@options = args.last.is_a?(Hash) ? args.pop : {}
- @redis = args.first || $redis || Redis.current
+ @redis = args.first || Objects.redis
end
alias :inspect :to_s # Ruby 1.9.2
Something went wrong with that request. Please try again.