class RediSearch::Client
Attributes
pipeline[RW]
redis[R]
Public Class Methods
new(redis = Redis.new)
click to toggle source
# File lib/redi_search/client.rb, line 10 def initialize(redis = Redis.new) @redis = redis @pipeline = false end
Public Instance Methods
call!(command, *params, skip_ft: false)
click to toggle source
# File lib/redi_search/client.rb, line 15 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
multi() { || ... }
click to toggle source
# File lib/redi_search/client.rb, line 22 def multi Response.new(redis.multi do instrument("pipeline", query: ["begin pipeline"]) capture_pipeline { yield } instrument("pipeline", query: ["finish pipeline"]) end) end
Private Instance Methods
capture_pipeline() { || ... }
click to toggle source
# File lib/redi_search/client.rb, line 35 def capture_pipeline self.pipeline = true yield self.pipeline = false end
instrument(action, payload, &block)
click to toggle source
# File lib/redi_search/client.rb, line 45 def instrument(action, payload, &block) ActiveSupport::Notifications.instrument( "action.redi_search", { name: "RediSearch", action: action, inside_pipeline: pipeline }. merge(payload), &Proc.new(&(block || proc {})) # rubocop:disable Lint/EmptyBlock ) end
send_command(command, *params)
click to toggle source
# File lib/redi_search/client.rb, line 41 def send_command(command, *params) Response.new(redis.call(command, *params)) end