Browse files

BackgroundCache::Daemon.queued -> BackgroundCache::Client#queued

  • Loading branch information...
1 parent 89ea239 commit 33e22e343c9873997ab28e32aec7abc4c9beaf32 @winton committed Nov 3, 2011
Showing with 13 additions and 18 deletions.
  1. +7 −0 lib/background_cache/client.rb
  2. +6 −18 lib/background_cache/daemon.rb
View
7 lib/background_cache/client.rb
@@ -42,5 +42,12 @@ def cache(options)
response
end
+
+ def queued
+ queues = @redis_2.keys 'background_cache:queue:*'
+ queues.collect do |q|
+ queue['background_cache:queue:'.length..-1]
+ end
+ end
end
end
View
24 lib/background_cache/daemon.rb
@@ -11,7 +11,12 @@ module BackgroundCache
class Daemon
def initialize(root)
- options = self.class.options
+ if File.exists?(yaml = "#{root}/config/background_cache.yml")
+ options = YAML.load(File.read(yaml))
+ else
+ puts "\nFAIL: config/background_cache.yml not found"
+ shut_down
+ end
puts "\nStarting background cache server (redis @ #{options['redis']})..."
@@ -78,22 +83,5 @@ def shut_down
puts "\nShutting down background cache server..."
exit
end
-
- def self.options
- if File.exists?(yaml = "#{root}/config/background_cache.yml")
- YAML.load(File.read(yaml))
- else
- puts "\nFAIL: config/background_cache.yml not found"
- shut_down
- end
- end
-
- def self.queued
- redis = Redis.connect(:url => "redis://#{options['redis']}")
- queues = redis.keys 'background_cache:queue:*'
- queues.collect do |q|
- queue['background_cache:queue:'.length..-1]
- end
- end
end
end

0 comments on commit 33e22e3

Please sign in to comment.