Sha256: 1a6dcf11aebaa31e5ae554615a94c8e114e830e65de97fbe915824161882af85

Contents?: true

Size: 802 Bytes

Versions: 1

Compression:

Stored size: 802 Bytes

Contents

module Daybreak
  # Class for building out the table, you shouldn't need to access this
  # class directly. Readers are responsible for reading each record in
  # the file and yeilding the parsed records.
  class Reader
    # @param [String] file the file to read from
    def initialize(file)
      @file_name = file
    end

    # Read all values from the aof file.
    #
    # Right now this is really expensive, every call to read will
    # close and reread the whole db file, but since cross process
    # consistency is handled by the user, this should be fair warning.
    def read
      File.open(@file_name, 'r') do |fd|
        fd.binmode
        fd.advise(:sequential) if fd.respond_to? :advise
        while !fd.eof?
          yield Record.read(fd)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
daybreak-0.1.2 lib/daybreak/reader.rb