Sha256: f82291695ef0b8a36ac65eef1360a40375774edc4c18214d570e543564cdf4f6
Contents?: true
Size: 964 Bytes
Versions: 1
Compression:
Stored size: 964 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 = @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 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.pre2 | lib/ffi/hiredis_vip/sadd.rb |