Sha256: 0cdccd6665ce511481736f5bc365e532724c5141b07e1bccead1ade5e5ee4371
Contents?: true
Size: 1.05 KB
Versions: 1
Compression:
Stored size: 1.05 KB
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 = [ :pointer, key, :size_t, key.size ] values.each do |value| value = value.to_s command_args << :pointer << value << :size_t << value.size end synchronize do |connection| reply = @client.execute_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 ensure ::FFI::HiredisVip::Core.freeReplyObject(reply.pointer) if reply 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.pre4 | lib/ffi/hiredis_vip/sadd.rb |