Created
July 29, 2011 09:28
-
-
Save ondrejbartas/1113508 to your computer and use it in GitHub Desktop.
Connection to redis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RedisConnect | |
@@db_redis = nil | |
@@db_adtext_redis = nil | |
def self.redis | |
if @@db_redis.nil? | |
config = YAML.load_file('config/database.yml')[ENV['RACK_ENV']] | |
@@db_redis = Redis.new(:host => config["host"], :port => config["port"], :db => config["db"]) | |
end | |
return @@db_redis | |
end | |
def self.adtext | |
if @@db_adtext_redis.nil? | |
config = YAML.load_file('config/database.yml')[ENV['RACK_ENV']] | |
@@db_adtext_redis = Redis.new(:host => config["host"], :port => config["port"], :db => config["adtext_db"]) | |
end | |
return @@db_adtext_redis | |
end | |
end | |
RedisConnect.redis.keys("zkouska") | |
RedisConnect.redis.keys("zkouska1") | |
RedisConnect.redis.keys("zkouska2") | |
RedisConnect.redis.keys("zkouska3") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment