Sha256: 60c3d6b753c1691293395ad4c791158ee5320211c87f567d03a04c7f0c561722
Contents?: true
Size: 972 Bytes
Versions: 1
Compression:
Stored size: 972 Bytes
Contents
module FFI module HiredisVip class Sadd def initialize(client) @client = client end def sadd(key, *values) reply = nil values = values.flatten number_of_values = values.size command = "SADD %b#{' %b' * number_of_values}" command_args = [ :string, key, :size_t, key.size ] values.each do |value| command_args << :string << value << :size_t << value.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 private def synchronize @client.synchronize do |connection| yield(connection) end end end # class Sadd 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/sadd.rb |