Ich habe CouchBase-Server.CouchBase-Ausnahme. Das Dokument wurde mutiert
Und habe eine Frage zu gleichzeitige Dokument Mutationen: http://developer.couchbase.com/documentation/server/4.0/developer-guide/cas-concurrency.html
Code-Beispiel mit dem Speichern von Daten in Couchbase:
try {
Yii::$app->Couch->set($key, $data, 0, '', 1);
} catch (\Exception $e) {
$already_saved = Yii::$app->Couch->get($key);
Yii::$app->Logger->alert(
'CouchBase exception',
[
'exception' => $e->getMessage(),
'key' => $key,
'need_saved' => $data,
'already_saved' => $already_saved,
'equal' => md5($already_saved)==md5(json_encode($data))
]
);
}
/**
* Store a document in the cluster.
*
* The set operation stores a document in the cluster. It differs from
* add and replace in that it does not care for the presence of
* the identifier in the cluster.
*
* If the $cas field is specified, set will <b>only</b> succeed if the
* identifier exists in the cluster with the <b>exact</b> same cas value
* as the one specified in this request.
*
* @param string $id the identifier to store the document under
* @param object|string $document the document to store
* @param integer $expiry the lifetime of the document (0 == infinite)
* @param string $cas a cas identifier to restrict the store operation
* @param integer $persist_to wait until the document is persisted to (at least)
* this many nodes
* @param integer $replicate_to wait until the document is replicated to (at least)
* this many nodes
* @return string the cas value of the object if success
* @throws CouchbaseException if an error occurs
*/
function set($id, $document, $expiry = 0, $cas = "", $persist_to = 0, $replicate_to = 0) {
}
aber weniger als 0,002% aus Alle Nachrichten, die ich erhalte Ausnahme:
CouchBase-Ausnahme. Das Dokument wurde mutiert.
So finden Sie in der Dokumentation:
CAS ist ein Akronym für Vergleichs- und Auslagerungs, und wird als eine Form von optimistischen Sperren bekannt. Der CAS kann von Anwendungen an Mutationsoperationen geliefert werden (einfügen, upsert, ersetzen). Wenn Anwendungen die CAS bieten, werden Server die Anwendung bereitgestellte überprüfen Version von CAS gegen seine eigene Version des CAS:
Wenn die beiden CAS Werte übereinstimmen (sie vergleichen erfolgreich), dann ist die Mutation Operation erfolgreich .
Wenn die beiden CAS-Werte unterscheiden, dann ist die Mutation Operation fehlschlägt
aber immer noch nicht verstehen, was diese Mutation bedeutet?
Warum wenn CAS Werte übereinstimmen, dann ist die Mutationsoperation erfolgreich ist, ist es nicht nur Nachrichtendaten neu zu schreiben?
Warum, wenn sich die Werte unterscheiden, schlägt die Mutationsoperation fehl?
Warum erhalte ich diese Ausnahme?
Kann mir jemand helfen? –
Jeder weiß es? –