class Photish::Cache::Repository
Attributes
output_dir[R]
worker_db_file_cache[R]
workers[R]
Public Class Methods
new(output_dir, workers)
click to toggle source
# File lib/photish/cache/repository.rb, line 4 def initialize(output_dir, workers) @output_dir = output_dir @workers = workers @worker_db_file_cache = {} end
Public Instance Methods
concat_worker_db_files()
click to toggle source
# File lib/photish/cache/repository.rb, line 14 def concat_worker_db_files master_db_file.write(accumulate_changes) end
master_db_file()
click to toggle source
# File lib/photish/cache/repository.rb, line 18 def master_db_file @master_db_file ||= DbFile.new_master(output_dir) end
worker_db_file(index)
click to toggle source
# File lib/photish/cache/repository.rb, line 22 def worker_db_file(index) worker_db_file_cache.fetch(index) do DbFile.new_worker(output_dir, index) end end
Private Instance Methods
accumulate_changes()
click to toggle source
# File lib/photish/cache/repository.rb, line 34 def accumulate_changes (1..workers).inject({}) do |accumulator, worker_index| db_file = worker_db_file(worker_index) accumulator.merge(db_file.read) end end