Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

BackgroundCache::Daemon.queued

  • Loading branch information...
commit 89ea23914d3f57024c292dbf3662b6d38fc3e05c 1 parent c7b2ae4
@winton authored
Showing with 18 additions and 6 deletions.
  1. +18 −6 lib/background_cache/daemon.rb
View
24 lib/background_cache/daemon.rb
@@ -11,12 +11,7 @@ module BackgroundCache
class Daemon
def initialize(root)
- if File.exists?(yaml = "#{root}/config/background_cache.yml")
- options = YAML.load(File.read(yaml))
- else
- puts "\nFAIL: config/background_cache.yml not found"
- shutdown
- end
+ options = self.class.options
puts "\nStarting background cache server (redis @ #{options['redis']})..."
@@ -83,5 +78,22 @@ 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
Please sign in to comment.
Something went wrong with that request. Please try again.