Sha256: 4b2c43397e5aac2ed1331c4cfc1fa3933c33beab980e47e139daee263d0ddaab

Contents?: true

Size: 798 Bytes

Versions: 1

Compression:

Stored size: 798 Bytes

Contents

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

      def exists(*keys)
        reply = nil
        keys = keys.flatten
        number_of_exists = keys.size
        command = "EXISTS#{' %b' * number_of_exists}"
        command_args = []
        keys.each do |key|
          command_args << :string << key << :size_t << key.size
        end

        @client.synchronize do |connection|
          reply = ::FFI::HiredisVip::Core.command(connection, command, *command_args)
        end

        return nil if reply.nil? || reply.null?

        case reply[:type] 
        when :REDIS_REPLY_INTEGER
          reply[:integer]
        else
          0
        end
      end
    end # class Exists
  end # module HiredisVip
end # module FFI

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ffi-hiredis_vip-0.1.0.pre1 lib/ffi/hiredis_vip/exists.rb