lib/upperkut/strategy.rb in upperkut-0.1.2 vs lib/upperkut/strategy.rb in upperkut-0.1.3

- old
+ new

@@ -10,12 +10,13 @@ self.worker = worker self.redis = redis end def push_items(items = []) + items = [items] if items.is_a?(Hash) return false if items.empty? - redis.lpush(key, encode_json_items(items)) + redis.rpush(key, encode_json_items(items)) end def fetch_items(batch_size = 1000) stop = [batch_size, size].min @@ -37,9 +38,13 @@ item = decode_json_items(item).first return 0 unless item now = Time.now.to_f lat = now - item.fetch('enqueued_at', Time.now).to_f lat + end + + def clear + redis.del(key) end private def key