Module: ThinkingSphinx::Deltas::ResqueDelta::FlagAsDeletedSet

Extended by:
FlagAsDeletedSet
Included in:
FlagAsDeletedSet
Defined in:
lib/thinking_sphinx/deltas/resque_delta/flag_as_deleted_set.rb

Instance Method Summary collapse

Instance Method Details

#add(core_name, document_id) ⇒ Object



17
18
19
# File 'lib/thinking_sphinx/deltas/resque_delta/flag_as_deleted_set.rb', line 17

def add(core_name, document_id)
  Resque.redis.sadd(set_name(core_name), document_id)
end

#clear!(core_name) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/thinking_sphinx/deltas/resque_delta/flag_as_deleted_set.rb', line 21

def clear!(core_name)
  Resque.redis.del(set_name(core_name))

  #Clear processing set as well
  delta_name = ThinkingSphinx::Deltas::ResqueDelta::IndexUtils.core_to_delta(core_name)
  ThinkingSphinx::Deltas::ResqueDelta::DeltaJob.around_perform_lock(delta_name) do
    Resque.redis.del(processing_name(core_name))
  end
end

#clear_all!Object



31
32
33
34
35
# File 'lib/thinking_sphinx/deltas/resque_delta/flag_as_deleted_set.rb', line 31

def clear_all!
  ThinkingSphinx::Deltas::ResqueDelta::IndexUtils.core_indices.each do |core_index|
    clear!(core_index)
  end
end

#clear_processing(core_name) ⇒ Object



52
53
54
# File 'lib/thinking_sphinx/deltas/resque_delta/flag_as_deleted_set.rb', line 52

def clear_processing(core_name)
  Resque.redis.del(processing_name(core_name))
end

#get_subset_for_processing(core_name) ⇒ Object



37
38
39
40
41
42
43
44
45
46
# File 'lib/thinking_sphinx/deltas/resque_delta/flag_as_deleted_set.rb', line 37

def get_subset_for_processing(core_name)
  # Copy set to temp
  Resque.redis.sunionstore temp_name(core_name), set_name(core_name)
  # Store (set - temp) into set.  This removes all items we copied into temp from set.
  Resque.redis.sdiffstore set_name(core_name), set_name(core_name), temp_name(core_name)
  # Merge processing and temp together and store into processing.
  Resque.redis.sunionstore processing_name(core_name), processing_name(core_name), temp_name(core_name)

  Resque.redis.del temp_name(core_name)
end

#processing_members(core_name) ⇒ Object



48
49
50
# File 'lib/thinking_sphinx/deltas/resque_delta/flag_as_deleted_set.rb', line 48

def processing_members(core_name)
  Resque.redis.smembers(processing_name(core_name)).collect(&:to_i)
end

#processing_name(core_name) ⇒ Object



13
14
15
# File 'lib/thinking_sphinx/deltas/resque_delta/flag_as_deleted_set.rb', line 13

def processing_name(core_name)
  "#{ThinkingSphinx::Deltas::ResqueDelta.job_prefix}:flag.deleted:#{core_name}:processing"
end

#set_name(core_name) ⇒ Object



5
6
7
# File 'lib/thinking_sphinx/deltas/resque_delta/flag_as_deleted_set.rb', line 5

def set_name(core_name)
  "#{ThinkingSphinx::Deltas::ResqueDelta.job_prefix}:flag.deleted:#{core_name}:set"
end

#temp_name(core_name) ⇒ Object



9
10
11
# File 'lib/thinking_sphinx/deltas/resque_delta/flag_as_deleted_set.rb', line 9

def temp_name(core_name)
  "#{ThinkingSphinx::Deltas::ResqueDelta.job_prefix}:flag.deleted:#{core_name}:temp"
end