Class: ThinkingSphinx::Deltas::ResqueDelta

Inherits:
DefaultDelta
  • Object
show all
Includes:
Binary, SphinxQL
Defined in:
lib/thinking_sphinx/deltas/resque_delta.rb

Overview

Delayed Deltas for Thinking Sphinx, using Resque.

This documentation is aimed at those reading the code. If you’re looking for a guide to Thinking Sphinx and/or deltas, I recommend you start with the Thinking Sphinx site instead - or the README for this library at the very least.

See Also:

Author:

  • Patrick Allan

Defined Under Namespace

Modules: Binary, SphinxQL

Constant Summary collapse

JOB_PREFIX =
'ts-delta'

Class Method Summary collapse

Methods included from SphinxQL

#delete, #index

Methods included from Binary

#index

Class Method Details

.cancel_jobsObject

LTRIM + LPOP deletes all items from the Resque queue without loading it into client memory (unlike Resque.dequeue). WARNING: This will clear ALL jobs in any queue used by a ResqueDelta job. If you’re sharing a queue with other jobs they’ll be deleted!



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

def self.cancel_jobs
  job_types.collect { |klass|
    klass.instance_variable_get :@queue
  }.uniq.each do |queue|
    Resque.redis.ltrim "queue:#{queue}", 0, 0
    Resque.redis.lpop  "queue:#{queue}"
  end
end

.job_typesObject



17
18
19
20
21
22
# File 'lib/thinking_sphinx/deltas/resque_delta.rb', line 17

def self.job_types
  [
    ThinkingSphinx::Deltas::ResqueDelta::DeltaJob,
    ThinkingSphinx::Deltas::ResqueDelta::FlagAsDeletedJob
  ]
end