class RediSearcher::Client

Attributes

redis[RW]

Public Class Methods

new(redis = {}, *args) click to toggle source
# File lib/redi_searcher/client.rb, line 4
def initialize(redis = {}, *args)
  @redis = Redis.new(redis)
end

Public Instance Methods

call(command) click to toggle source
# File lib/redi_searcher/client.rb, line 12
def call(command)
  raise ArgumentError.new("unknown/unsupported command '#{command.first}'") unless valid_command?(command.first)
  with_reconnect { @redis.call(command.flatten) }
end
generate_index(name, schema) click to toggle source
# File lib/redi_searcher/client.rb, line 8
def generate_index(name, schema)
  RediSearcher::Index.new(self, name, schema)
end
multi() { || ... } click to toggle source

return true or false

# File lib/redi_searcher/client.rb, line 18
def multi
  with_reconnect { @redis.multi { yield } }
end

Private Instance Methods

valid_command?(command) click to toggle source
# File lib/redi_searcher/client.rb, line 30
def valid_command?(command)
  %w(FT.CREATE FT.ADD FT.ADDHASH FT.SEARCH FT.DEL FT.DROP FT.GET FT.MGET
     FT.SUGADD FT.SUGGET FT.SUGDEL FT.SUGLEN FT.SYNADD FT.SYNUPDATE FT.SYNDUMP
     FT.INFO FT.AGGREGATE FT.EXPLAIN FT.TAGVALS FT.CONFIG).include?(command)
end
with_reconnect() { || ... } click to toggle source
# File lib/redi_searcher/client.rb, line 26
def with_reconnect
  @redis.with_reconnect { yield }
end