Class: Mnemosyne::Sweeper
- Inherits:
-
Object
- Object
- Mnemosyne::Sweeper
- Includes:
- Helper
- Defined in:
- lib/mneme/sweeper.rb
Instance Method Summary collapse
-
#initialize(port, config, status, logger) ⇒ Sweeper
constructor
A new instance of Sweeper.
- #run ⇒ Object
Methods included from Helper
Constructor Details
#initialize(port, config, status, logger) ⇒ Sweeper
Returns a new instance of Sweeper.
5 6 7 8 9 |
# File 'lib/mneme/sweeper.rb', line 5 def initialize(port, config, status, logger) @status = status @config = config @logger = logger end |
Instance Method Details
#run ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/mneme/sweeper.rb', line 11 def run if @config.empty? puts "Please specify a valid mneme configuration file (ex: -c config.rb)" EM.stop exit end sweeper = Proc.new do Fiber.new do current = epoch_name(@config['namespace'], 0, @config['length']) @logger.info "Sweeping old filters, current epoch: #{current}" conn = Redis.new @config['periods'].times do |n| name = epoch_name(@config['namespace'], n + @config['periods'], @config['length']) conn.del(name) @logger.info "Removed: #{name}" end conn.client.disconnect end.resume end sweeper.call EM.add_periodic_timer(@config['length']) { sweeper.call } @logger.info "Started Mnemosyne::Sweeper with #{@config['length']}s interval" end |