Class: RediSearch::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/redi_search/client.rb,
lib/redi_search/client/response.rb

Defined Under Namespace

Classes: Response

Instance Method Summary collapse

Constructor Details

#initialize(redis = Redis.new) ⇒ Client

Returns a new instance of Client.



7
8
9
10
# File 'lib/redi_search/client.rb', line 7

def initialize(redis = Redis.new)
  @redis = redis
  @pipeline = false
end

Instance Method Details

#call!(command, *params, skip_ft: false) ⇒ Object



12
13
14
15
16
17
# File 'lib/redi_search/client.rb', line 12

def call!(command, *params, skip_ft: false)
  instrument(command.downcase, query: [command, params]) do
    command = "FT.#{command}" unless skip_ft
    send_command(command, *params)
  end
end

#multiObject



19
20
21
22
23
24
25
26
# File 'lib/redi_search/client.rb', line 19

def multi
  instrument("pipeline", query: ["begin pipeline"])
  Response.new(redis.pipelined do |pipeline|
    capture_pipeline(pipeline) { yield }
  end)
ensure
  instrument("pipeline", query: ["finish pipeline"])
end