Class: OpenC3::StoreConnectionPool

Inherits:
ConnectionPool
  • Object
show all
Defined in:
lib/openc3/utilities/store_autoload.rb

Constant Summary collapse

NO_OPTIONS =
{}

Instance Method Summary collapse

Instance Method Details

#pipelinedObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/openc3/utilities/store_autoload.rb', line 39

def pipelined
  if $openc3_redis_cluster
    yield # TODO: Update keys to support pipelining in cluster
  else
    with(NO_OPTIONS) do |redis|
      redis.pipelined do |pipeline|
        Thread.current[:pipeline] = pipeline
        begin
          yield
        ensure
          Thread.current[:pipeline] = nil
        end
      end
    end
  end
end

#with(options = NO_OPTIONS, &block) ⇒ Object



56
57
58
59
60
61
62
63
# File 'lib/openc3/utilities/store_autoload.rb', line 56

def with(options = NO_OPTIONS, &block)
  pipeline = Thread.current[:pipeline]
  if pipeline
    yield pipeline
  else
    super(options, &block)
  end
end