2929-module (mero_dummy_server ).
3030
3131-include_lib (" mero/include/mero.hrl" ).
32- -include_lib (" eunit/include/eunit.hrl" ).
3332
3433-author ('Miriam Pena <miriam.pena@adroll.com>' ).
3534
@@ -248,23 +247,23 @@ parse(Request) ->
248247
249248% %%% Response
250249
251- canned_responses (text , _Index , _Key , _Op , not_found ) ->
250+ canned_responses (text , _Index , _Op , not_found ) ->
252251 [" NOT_FOUND" , <<" \r\n " >>];
253- canned_responses (text , _Index , _Key , _Op , not_stored ) ->
252+ canned_responses (text , _Index , _Op , not_stored ) ->
254253 [" NOT_STORED" , <<" \r\n " >>];
255- canned_responses (text , _Index , _Key , _Op , stored ) ->
254+ canned_responses (text , _Index , _Op , stored ) ->
256255 [<<" STORED" >>, <<" \r\n " >>];
257- canned_responses (text , _Index , _Key , _Op , already_exists ) ->
256+ canned_responses (text , _Index , _Op , already_exists ) ->
258257 [<<" EXISTS" >>, <<" \r\n " >>];
259- canned_responses (text , _Index , _Key , _Op , deleted ) ->
258+ canned_responses (text , _Index , _Op , deleted ) ->
260259 [<<" DELETED" >>, <<" \r\n " >>];
261- canned_responses (text , _Index , _Key , _Op , flushed ) ->
260+ canned_responses (text , _Index , _Op , flushed ) ->
262261 [<<" FLUSHED" >>, <<" \r\n " >>];
263- canned_responses (text , _Index , _Key , _Op , {incr , I }) ->
262+ canned_responses (text , _Index , _Op , {incr , I }) ->
264263 [mero_util :to_bin (I ), <<" \r\n " >>];
265- canned_responses (text , _Index , _Key , _Op , noop ) ->
264+ canned_responses (text , _Index , _Op , noop ) ->
266265 [];
267- canned_responses (binary , Index , _Key , Op , not_found ) ->
266+ canned_responses (binary , Index , Op , not_found ) ->
268267 ExtrasOut = <<>>,
269268 ExtrasSizeOut = size (ExtrasOut ),
270269 Status = ? NOT_FOUND ,
@@ -281,7 +280,7 @@ canned_responses(binary, Index, _Key, Op, not_found) ->
281280 (opaque (Index )):32 ,
282281 0 :64 ,
283282 BodyOut /binary >>;
284- canned_responses (binary , Index , _Key , Op , not_stored ) ->
283+ canned_responses (binary , Index , Op , not_stored ) ->
285284 ExtrasOut = <<>>,
286285 ExtrasSizeOut = size (ExtrasOut ),
287286 Status = ? NOT_STORED ,
@@ -299,7 +298,7 @@ canned_responses(binary, Index, _Key, Op, not_stored) ->
299298 (opaque (Index )):32 ,
300299 0 :64 ,
301300 BodyOut /binary >>;
302- canned_responses (binary , Index , _Key , Op , stored ) ->
301+ canned_responses (binary , Index , Op , stored ) ->
303302 ExtrasOut = <<>>,
304303 ExtrasSizeOut = size (ExtrasOut ),
305304 Status = ? NO_ERROR ,
@@ -319,7 +318,6 @@ canned_responses(binary, Index, _Key, Op, stored) ->
319318 BodyOut /binary >>;
320319canned_responses (binary ,
321320 Index ,
322- _Key ,
323321 Op ,
324322 deleted ) -> % % same as stored, intentionally
325323 ExtrasOut = <<>>,
@@ -339,7 +337,7 @@ canned_responses(binary,
339337 (opaque (Index )):32 ,
340338 0 :64 ,
341339 BodyOut /binary >>;
342- canned_responses (binary , Index , _Key , ? MEMCACHE_INCREMENT , {incr , I }) ->
340+ canned_responses (binary , Index , ? MEMCACHE_INCREMENT , {incr , I }) ->
343341 ExtrasOut = <<>>,
344342 ExtrasSizeOut = size (ExtrasOut ),
345343 Status = ? NO_ERROR ,
@@ -357,7 +355,7 @@ canned_responses(binary, Index, _Key, ?MEMCACHE_INCREMENT, {incr, I}) ->
357355 (opaque (Index )):32 ,
358356 0 :64 ,
359357 BodyOut /binary >>;
360- canned_responses (binary , Index , _Key , Op , already_exists ) ->
358+ canned_responses (binary , Index , Op , already_exists ) ->
361359 ExtrasOut = <<>>,
362360 ExtrasSizeOut = size (ExtrasOut ),
363361 Status = ? KEY_EXISTS ,
@@ -375,7 +373,7 @@ canned_responses(binary, Index, _Key, Op, already_exists) ->
375373 (opaque (Index )):32 ,
376374 0 :64 ,
377375 BodyOut /binary >>;
378- canned_responses (binary , _Index , _Key , Op , flushed ) ->
376+ canned_responses (binary , _Index , Op , flushed ) ->
379377 ExtrasOut = <<>>,
380378 ExtrasSizeOut = size (ExtrasOut ),
381379 Status = ? NO_ERROR ,
@@ -393,7 +391,7 @@ canned_responses(binary, _Index, _Key, Op, flushed) ->
393391 16#00 :32 ,
394392 0 :64 ,
395393 BodyOut /binary >>;
396- canned_responses (binary , _Index , _Key , _Op , noop ) ->
394+ canned_responses (binary , _Index , _Op , noop ) ->
397395 [].
398396
399397opaque (undefined ) ->
@@ -479,7 +477,7 @@ response(Parent, Port, Request) ->
479477 case {Kind , Cmd } of
480478 {Kind , flush_all } ->
481479 flush_all (Parent , Port ),
482- canned_responses (Kind , undefined , undefined , ? MEMCACHE_FLUSH_ALL , flushed );
480+ canned_responses (Kind , undefined , ? MEMCACHE_FLUSH_ALL , flushed );
483481 {Kind , {get , Keys }} ->
484482 case Kind of
485483 text ->
@@ -501,7 +499,7 @@ response(Parent, Port, Request) ->
501499 <<>>;
502500 {Kind , {set , Key , Bytes , Index , false }} ->
503501 put_key (Parent , Port , Key , Bytes ),
504- canned_responses (Kind , Index , Key , ? MEMCACHE_SET , stored );
502+ canned_responses (Kind , Index , ? MEMCACHE_SET , stored );
505503 {Kind , {cas , Key , Bytes , CAS , Index , Quiet }} ->
506504 Op = case Quiet of
507505 true ->
@@ -512,31 +510,31 @@ response(Parent, Port, Request) ->
512510 case get_key (Parent , Port , Key ) of
513511 undefined ->
514512 ct :log (" cas of non-existent key ~p " , [Key ]),
515- canned_responses (Kind , Index , Key , Op , not_found );
513+ canned_responses (Kind , Index , Op , not_found );
516514 {_ , CAS } ->
517515 ct :log (" cas of existing key ~p with correct token ~p " , [Key , CAS ]),
518516 put_key (Parent , Port , Key , Bytes , CAS + 1 ),
519517 case Quiet of
520518 true ->
521519 <<>>;
522520 false ->
523- canned_responses (Kind , Index , Key , Op , stored )
521+ canned_responses (Kind , Index , Op , stored )
524522 end ;
525523 {_ , ExpectedCAS } ->
526524 ct :log (" cas of existing key ~p with incorrect token ~p (wanted ~p )" ,
527525 [Key , CAS , ExpectedCAS ]),
528- canned_responses (Kind , Index , Key , Op , already_exists )
526+ canned_responses (Kind , Index , Op , already_exists )
529527 end ;
530528 {Kind , {delete , Key }} ->
531529 ct :log (" deleting ~p " , [Key ]),
532530 case get_key (Parent , Port , Key ) of
533531 undefined ->
534532 ct :log (" was not present" ),
535- canned_responses (Kind , undefined , Key , ? MEMCACHE_DELETE , not_found );
533+ canned_responses (Kind , undefined , ? MEMCACHE_DELETE , not_found );
536534 {_Value , _ } ->
537535 ct :log (" key was present" ),
538536 put_key (Parent , Port , Key , undefined , undefined ),
539- canned_responses (Kind , undefined , Key , ? MEMCACHE_DELETE , deleted )
537+ canned_responses (Kind , undefined , ? MEMCACHE_DELETE , deleted )
540538 end ;
541539 {Kind , {add , Key , Bytes , Index , Quiet }} ->
542540 Op = case Quiet of
@@ -552,34 +550,29 @@ response(Parent, Port, Request) ->
552550 true ->
553551 <<>>;
554552 false ->
555- canned_responses (Kind , Index , Key , Op , stored )
553+ canned_responses (Kind , Index , Op , stored )
556554 end ;
557555 {_Value , _ } ->
558- canned_responses (Kind , Index , Key , Op , already_exists )
556+ canned_responses (Kind , Index , Op , already_exists )
559557 end ;
560558 {Kind , {incr , Key , ExpTime , Initial , Bytes }} ->
561559 case get_key (Parent , Port , Key ) of
562560 undefined ->
563561 % % Return error
564562 case ExpTime of
565563 4294967295 -> % % 32 bits, all 1
566- canned_responses (Kind ,
567- undefined ,
568- Key ,
569- ? MEMCACHE_INCREMENT ,
570- not_found );
564+ canned_responses (Kind , undefined , ? MEMCACHE_INCREMENT , not_found );
571565 _ ->
572566 put_key (Parent , Port , Key , Initial ),
573567 canned_responses (Kind ,
574568 undefined ,
575- Key ,
576569 ? MEMCACHE_INCREMENT ,
577570 {incr , Initial })
578571 end ;
579572 {Value , _ } ->
580573 Result = mero_util :to_int (Value ) + mero_util :to_int (Bytes ),
581574 put_key (Parent , Port , Key , Result ),
582- canned_responses (Kind , undefined , Key , ? MEMCACHE_INCREMENT , {incr , Result })
575+ canned_responses (Kind , undefined , ? MEMCACHE_INCREMENT , {incr , Result })
583576 end
584577 end ,
585578 {Response , Unparsed }.
0 commit comments