MCPcopy
hub / github.com/dropbox/godropbox / mutateMulti

Method mutateMulti

memcache/raw_binary_client.go:461–500  ·  view source on GitHub ↗

Batch version of the mutate method. Note that the response entries ordering is undefined (i.e., may not match the input ordering) When DataVersionId is 0, zeroVersionIdCode is used instead of code.

(
	code opCode, zeroVersionIdCode opCode,
	items []*Item)

Source from the content-addressed store, hash-verified

459// ordering is undefined (i.e., may not match the input ordering)
460// When DataVersionId is 0, zeroVersionIdCode is used instead of code.
461func (c *RawBinaryClient) mutateMulti(
462 code opCode, zeroVersionIdCode opCode,
463 items []*Item) []MutateResponse {
464
465 if items == nil {
466 return nil
467 }
468
469 responses := make([]MutateResponse, len(items), len(items))
470
471 // Short-circuit function to avoid locking.
472 if len(items) == 0 {
473 return responses
474 }
475
476 c.mutex.Lock()
477 defer c.mutex.Unlock()
478
479 var itemCode opCode
480 for i, item := range items {
481 itemCode = code
482 if item.DataVersionId == 0 {
483 itemCode = zeroVersionIdCode
484 }
485 responses[i] = c.sendMutateRequest(itemCode, item, true)
486 }
487
488 for i, item := range items {
489 if responses[i] != nil { // error occurred while sending
490 continue
491 }
492 itemCode = code
493 if item.DataVersionId == 0 {
494 itemCode = zeroVersionIdCode
495 }
496 responses[i] = c.receiveMutateResponse(itemCode, item.Key)
497 }
498
499 return responses
500}
501
502// See Client interface for documentation.
503func (c *RawBinaryClient) Set(item *Item) MutateResponse {

Callers 3

SetMultiMethod · 0.95
CasMultiMethod · 0.95
AddMultiMethod · 0.95

Calls 4

sendMutateRequestMethod · 0.95
receiveMutateResponseMethod · 0.95
LockMethod · 0.65
UnlockMethod · 0.65

Tested by

no test coverage detected