Sha256: c7dc1977411253c7ec6e24c7e2c105f16ea625269600023eb59bde3e0d68ac00

Contents?: true

Size: 848 Bytes

Versions: 3

Compression:

Stored size: 848 Bytes

Contents

require 'connection_pool'

module Legion
  module Cache
    module Pool
      def connected?
        @connected ||= false
      end

      def size
        client.size
      end

      def timeout
        @timeout ||= Legion::Settings[:cache][:timeout] || 5
      end

      def pool_size
        @pool_size ||= Legion::Settings[:cache][:pool_size] || 10
      end

      def available
        client.available
      end

      def close
        client.shutdown(&:close)
        @client = nil
        @connected = false
      end

      def restart(**opts)
        close
        @client = nil
        client_hash = opts
        client_hash[:pool_size] = opts[:pool_size] if opts.key? :pool_size
        client_hash[:timeout] = opts[:timeout] if opts.key? :timeout
        client(**client_hash)
        @connected = true
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
legion-cache-1.2.0 lib/legion/cache/pool.rb
legion-cache-1.1.1 lib/legion/cache/pool.rb
legion-cache-1.1.0 lib/legion/cache/pool.rb