Sha256: 926c8f603fc666d4bf7b972902c831b29c806af755bcc41dd6ee108aa70afa08

Contents?: true

Size: 938 Bytes

Versions: 1

Compression:

Stored size: 938 Bytes

Contents

module FFI
  module HiredisVip
    class ExistsBefore3
      def initialize(client)
        @client = client
      end

      def exists(*keys)
        keys = keys.flatten
        number_of_exists = 0
        command = "EXISTS %b"

        keys.each do |key|
          begin
            reply = nil
            command_args = [ :pointer, key, :size_t, key.size ]
            @client.synchronize do |connection|
              reply = @client.execute_command(connection, command, *command_args)
            end

            next if reply.nil? || reply.null?

            case reply[:type] 
            when :REDIS_REPLY_INTEGER
              number_of_exists = number_of_exists + reply[:integer]
            end
          ensure
            ::FFI::HiredisVip::Core.freeReplyObject(reply.pointer) if reply
          end
        end

        number_of_exists
      end
    end # class ExistsBefore3
  end # module HiredisVip
end # module FFI

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ffi-hiredis_vip-0.1.0.pre4 lib/ffi/hiredis_vip/exists_before_3.rb