Module: Infinispan::Operation
- Includes:
- Constants, ResponseCode
- Defined in:
- lib/infinispan-ruby-client/remotecache.rb
Constant Summary collapse
- HEADER_ONLY_SEND =
lambda { |connection, | connection.write( HeaderBuilder.getHeader([:operation], [:cache]) ) }
- BULK_GET_SEND =
lambda { |connection, | connection.write( HeaderBuilder.getHeader([:operation], [:cache]) ) connection.write( Unsigned.encodeVint( [:count] ) ) }
- KEY_ONLY_SEND =
lambda { |connection, | connection.write( HeaderBuilder.getHeader([:operation], [:cache]) ) mkey = Marshal.dump( [:key] ) connection.write( Unsigned.encodeVint( mkey.size ) ) connection.write( mkey ) }
- KEY_VALUE_SEND =
lambda { |connection, | connection.write( HeaderBuilder.getHeader([:operation], [:cache]) ) # write key mkey = Marshal.dump( [:key] ) connection.write( Unsigned.encodeVint( mkey.size ) ) connection.write( mkey ) # lifespan + max_idle (not supported yet) connection.write( [0x00.chr,0x00.chr] ) # write value mkey = Marshal.dump( [:value] ) connection.write( Unsigned.encodeVint( mkey.size ) ) connection.write( mkey ) }
- REMOVE_IF_SEND =
lambda { |connection, | connection.write( HeaderBuilder.getHeader([:operation], [:cache]) ) # write key key = Marshal.dump( [:key] ) connection.write( Unsigned.encodeVint( key.size ) ) connection.write( key ) # write version connection.write( [:version] ) }
- REPLACE_IF_SEND =
lambda { |connection, | connection.write( HeaderBuilder.getHeader([:operation], [:cache]) ) # write key key = Marshal.dump( [:key] ) connection.write( Unsigned.encodeVint( key.size ) ) connection.write( key ) # lifespan + max_idle (not supported yet) connection.write( [0x00.chr,0x00.chr] ) # write version connection.write( [:version] ) # write value value = Marshal.dump( [:value] ) connection.write( Unsigned.encodeVint( value.size ) ) connection.write( value ) }
- KEY_ONLY_RECV =
lambda { |connection| connection.read( 5 ) # The response header response_body_length = Unsigned.decodeVint( connection ) response_body = connection.read( response_body_length ) Marshal.load( response_body ) }
- GET_WITH_VERSION_RECV =
lambda { |connection| response_header = connection.read( 5 ) # The response header 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 = {} response_header = connection.read( 5 ) # The response header more = connection.read(1).unpack('c')[0] while (more == 1) # The "more" flag 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| header = connection.read( 5 ) # Just the response header header[3] == SUCCESS }
Class Method Summary collapse
Class Method Details
.receive ⇒ Object
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/infinispan-ruby-client/remotecache.rb', line 122 def self.receive { GET[0] => KEY_ONLY_RECV, GET_WITH_VERSION[0] => GET_WITH_VERSION_RECV, BULK_GET[0] => BULK_GET_RECV, PUT[0] => BASIC_RECV, REMOVE[0] => BASIC_RECV, REMOVE_IF[0] => BASIC_RECV, CONTAINS[0] => BASIC_RECV, PUT_IF_ABSENT[0] => BASIC_RECV, REPLACE[0] => BASIC_RECV, REPLACE_IF[0] => BASIC_RECV, CLEAR[0] => BASIC_RECV, PING[0] => BASIC_RECV } end |
.send ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/infinispan-ruby-client/remotecache.rb', line 105 def self.send { GET[0] => KEY_ONLY_SEND, GET_WITH_VERSION[0] => KEY_ONLY_SEND, BULK_GET[0] => BULK_GET_SEND, PUT[0] => KEY_VALUE_SEND, REMOVE[0] => KEY_ONLY_SEND, REMOVE_IF[0] => REMOVE_IF_SEND, CONTAINS[0] => KEY_ONLY_SEND, PUT_IF_ABSENT[0] => KEY_VALUE_SEND, REPLACE[0] => KEY_VALUE_SEND, REPLACE_IF[0] => REPLACE_IF_SEND, CLEAR[0] => HEADER_ONLY_SEND, PING[0] => HEADER_ONLY_SEND } end |