lambda { |connection, options|
connection.write( HeaderBuilder.(options[:operation], options[:cache]) )
}
- BULK_GET_SEND =
lambda { |connection, options|
connection.write( HeaderBuilder.(options[:operation], options[:cache]) )
connection.write( Unsigned.encodeVint( options[:count] ) )
}
- KEY_ONLY_SEND =
lambda { |connection, options|
connection.write( HeaderBuilder.(options[:operation], options[:cache]) )
mkey = Marshal.dump( options[:key] )
connection.write( Unsigned.encodeVint( mkey.size ) )
connection.write( mkey )
}
- KEY_VALUE_SEND =
lambda { |connection, options|
connection.write( HeaderBuilder.(options[:operation], options[:cache]) )
mkey = Marshal.dump( options[:key] )
connection.write( Unsigned.encodeVint( mkey.size ) )
connection.write( mkey )
connection.write( [0x00.chr,0x00.chr] )
mkey = Marshal.dump( options[:value] )
connection.write( Unsigned.encodeVint( mkey.size ) )
connection.write( mkey )
}
- REMOVE_IF_SEND =
lambda { |connection, options|
connection.write( HeaderBuilder.(options[:operation], options[:cache]) )
key = Marshal.dump( options[:key] )
connection.write( Unsigned.encodeVint( key.size ) )
connection.write( key )
connection.write( options[:version] )
}
- REPLACE_IF_SEND =
lambda { |connection, options|
connection.write( HeaderBuilder.(options[:operation], options[:cache]) )
key = Marshal.dump( options[:key] )
connection.write( Unsigned.encodeVint( key.size ) )
connection.write( key )
connection.write( [0x00.chr,0x00.chr] )
connection.write( options[:version] )
value = Marshal.dump( options[:value] )
connection.write( Unsigned.encodeVint( value.size ) )
connection.write( value )
}
- KEY_ONLY_RECV =
lambda { |connection|
connection.read( 5 ) response_body_length = Unsigned.decodeVint( connection )
response_body = connection.read( response_body_length )
Marshal.load( response_body )
}
- GET_WITH_VERSION_RECV =
lambda { |connection|
= connection.read( 5 ) version = connection.read( 8 )
response_body_length = Unsigned.decodeVint( connection )
response_body = connection.read( response_body_length )
[ version, Marshal.load( response_body ) ]
}
- BULK_GET_RECV =
lambda { |connection|
response = {}
= connection.read( 5 ) more = connection.read(1).unpack('c')[0]
while (more == 1) key_length = Unsigned.decodeVint( connection )
key = connection.read( key_length )
value_length = Unsigned.decodeVint( connection )
value = connection.read( value_length )
response[Marshal.load(key)] = Marshal.load(value)
more = connection.read(1).unpack('c')[0]
end
response
}
- BASIC_RECV =
lambda { |connection|
= connection.read( 5 ) [3] == SUCCESS
}