module Flex::LiveReindex::Redis

private module

Constants

KEYS

Public Instance Methods

init() click to toggle source
# File lib/flex/live_reindex_admin.rb, line 34
def init
  begin
    require 'redis'
  rescue LoadError
    raise MissingRedisError, 'The live-reindex feature rely on redis. Please, install redis and the "redis" gem.'
  end
  raise MissingAppIdError, 'You must set the Flex::Configuration.app_id, and be sure you deploy it before live-reindexing.' \
        if Conf.app_id.nil? || Conf.app_id.empty?
  raise LiveReindexInProgressError, %(It looks like a live-reindex is in progress (PID #{get(:pid)}). If you are sure that there is no live-reindex in progress, please run the "flex:reset_redis_keys" rake task and retry.) \
        if get(:pid)
  reset_keys # just in case
  set(:pid, $$)
end
method_missing(command, key, *args) click to toggle source
# File lib/flex/live_reindex_admin.rb, line 25
def method_missing(command, key, *args)
  return unless Conf.redis
  Conf.redis.send(command, "#{KEYS[key]}-#{Conf.app_id}", *args)
end
reset_keys() click to toggle source
# File lib/flex/live_reindex_admin.rb, line 30
def reset_keys
  KEYS.keys.each { |k| del k }
end