Sha256: fdd785ee74098af2868089d2f4bab31b905db493ea69e516e8d3b5a4a86bd063

Contents?: true

Size: 838 Bytes

Versions: 1

Compression:

Stored size: 838 Bytes

Contents

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

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

        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

      def supports_touch?
        true
      end

    end # class Touch
  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/touch.rb