Sha256: a7bcbc736dc3ff66585681bb840d5163740dfadc991cf9933de418b36d4b5f4a

Contents?: true

Size: 790 Bytes

Versions: 1

Compression:

Stored size: 790 Bytes

Contents

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

      def persist(key)
        reply = nil
        command = "PERSIST %b"
        command_args = [ :string, key, :size_t, key.size ]
        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]
        end
      end

      def supports_persist?
        true
      end

      private

      def synchronize
        @client.synchronize do |connection|
          yield(connection)
        end
      end
    end # class Persist
  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/persist.rb