Class: CorrectHorseBatteryStaple::Writer::Redis
- Inherits:
-
Base
- Object
- CorrectHorseBatteryStaple::Writer
- Base
- CorrectHorseBatteryStaple::Writer::Redis
- Includes:
- Backend::Redis
- Defined in:
- lib/correct_horse_battery_staple/writer/redis.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(dest, options = {}) ⇒ Redis
constructor
A new instance of Redis.
- #write_corpus(corpus) ⇒ Object
Methods included from Backend::Redis
Methods inherited from Base
Methods included from Common
#array_sample, #logger, #random_in_range, #random_number, #set_sample
Methods inherited from CorrectHorseBatteryStaple::Writer
Constructor Details
#initialize(dest, options = {}) ⇒ Redis
Returns a new instance of Redis.
8 9 10 11 |
# File 'lib/correct_horse_battery_staple/writer/redis.rb', line 8 def initialize(dest, ={}) super parse_uri(dest) end |
Instance Method Details
#write_corpus(corpus) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/correct_horse_battery_staple/writer/redis.rb', line 13 def write_corpus(corpus) create_database open_database # this is faster and atomic (for some ops), but it doesn't allow RMW cycles db.multi do save_entries(corpus) save_stats(corpus.stats) end rescue logger.error "error in Redis write_corpus: #{$!.inspect}" raise ensure close_database end |