@@ -50,12 +50,18 @@ def write_multi_storage_req(_mode, pairs, ttl = nil, _cas = nil, options = {})
50
50
end
51
51
52
52
# rubocop:disable Metrics/AbcSize
53
+ # rubocop:disable Metrics/MethodLength
54
+ # rubocop:disable Metrics/CyclomaticComplexity
55
+ # rubocop:disable Metrics/PerceivedComplexity
53
56
def read_multi_req ( keys )
54
57
# Pre-allocate the results hash with expected size
55
58
results = SUPPORTS_CAPACITY ? Hash . new ( nil , capacity : keys . size ) : { }
59
+ optimized_for_raw = @value_marshaller . raw_by_default
60
+ key_index = optimized_for_raw ? 2 : 3
56
61
62
+ post_get_req = optimized_for_raw ? "v k q\r \n " : "v f k q\r \n "
57
63
keys . each do |key |
58
- @connection_manager . write ( "mg #{ key } v f k q \r \n " )
64
+ @connection_manager . write ( "mg #{ key } #{ post_get_req } " )
59
65
end
60
66
@connection_manager . write ( "mn\r \n " )
61
67
@connection_manager . flush
@@ -68,25 +74,42 @@ def read_multi_req(keys)
68
74
# VA value_length flags key
69
75
tokens = line . split
70
76
value = @connection_manager . read_exact ( tokens [ 1 ] . to_i )
77
+ bitflags = optimized_for_raw ? 0 : @response_processor . bitflags_from_tokens ( tokens )
71
78
@connection_manager . read_exact ( terminator_length ) # read the terminator
72
- results [ tokens [ 3 ] . byteslice ( 1 ..-1 ) ] =
73
- @value_marshaller . retrieve ( value , @response_processor . bitflags_from_tokens ( tokens ) )
79
+ results [ tokens [ key_index ] . byteslice ( 1 ..-1 ) ] =
80
+ @value_marshaller . retrieve ( value , bitflags )
74
81
end
75
82
results
76
83
end
77
84
# rubocop:enable Metrics/AbcSize
85
+ # rubocop:enable Metrics/MethodLength
86
+ # rubocop:enable Metrics/CyclomaticComplexity
87
+ # rubocop:enable Metrics/PerceivedComplexity
78
88
79
89
# Retrieval Commands
90
+ # rubocop:disable Metrics/AbcSize
91
+ # rubocop:disable Metrics/CyclomaticComplexity
92
+ # rubocop:disable Metrics/PerceivedComplexity
80
93
def get ( key , options = nil )
81
94
encoded_key , base64 = KeyRegularizer . encode ( key )
82
- req = RequestFormatter . meta_get ( key : encoded_key , base64 : base64 , meta_flags : meta_flag_options ( options ) )
83
- write ( req )
84
- if meta_flag_options ( options )
95
+ meta_options = meta_flag_options ( options )
96
+
97
+ if !meta_options && !base64 && !quiet? && @value_marshaller . raw_by_default
98
+ write ( "mg #{ encoded_key } v\r \n " )
99
+ else
100
+ write ( RequestFormatter . meta_get ( key : encoded_key , base64 : base64 , meta_flags : meta_options ) )
101
+ end
102
+ if !meta_options && !base64 && !quiet? && @value_marshaller . raw_by_default
103
+ response_processor . meta_get_with_value ( cache_nils : cache_nils? ( options ) , skip_flags : true )
104
+ elsif meta_options
85
105
response_processor . meta_get_with_value_and_meta_flags ( cache_nils : cache_nils? ( options ) )
86
106
else
87
107
response_processor . meta_get_with_value ( cache_nils : cache_nils? ( options ) )
88
108
end
89
109
end
110
+ # rubocop:enable Metrics/AbcSize
111
+ # rubocop:enable Metrics/CyclomaticComplexity
112
+ # rubocop:enable Metrics/PerceivedComplexity
90
113
91
114
def quiet_get_request ( key )
92
115
encoded_key , base64 = KeyRegularizer . encode ( key )
0 commit comments