1
0
Fork 0

Graph: Also refresh the cache if the rev is different

This commit is contained in:
Lucas Dohmen 2013-10-31 14:36:06 +01:00
parent 16328720d3
commit 3da8d973f9
1 changed files with 13 additions and 3 deletions

View File

@ -594,6 +594,14 @@ Graph.prototype._saveVertex = function (id, shallow, waitForSync) {
return this.constructVertex(ref._id);
};
////////////////////////////////////////////////////////////////////////////////
/// @brief replaces a vertex to the graph
////////////////////////////////////////////////////////////////////////////////
Graph.prototype._replaceVertex = function (vertex_id, data) {
var result = this._vertices.replace(vertex_id, data);
};
////////////////////////////////////////////////////////////////////////////////
/// @brief returns a vertex given its id
///
@ -825,17 +833,18 @@ Graph.prototype.setCachedPredecessors = function (target, source, value) {
////////////////////////////////////////////////////////////////////////////////
Graph.prototype.constructVertex = function (data) {
var id;
var id, rev;
if (typeof data === "string") {
id = data;
} else {
id = data._id;
rev = data._rev;
}
var vertex = this._verticesCache[id];
if (vertex === undefined) {
if (vertex === undefined || vertex._rev !== rev) {
var properties = this._vertices.document(id);
if (! properties) {
@ -859,11 +868,12 @@ Graph.prototype.constructEdge = function (data) {
id = data;
} else {
id = data._id;
rev = data._rev;
}
edge = this._edgesCache[id];
if (edge === undefined) {
if (edge === undefined || edge._rev !== rev) {
properties = this._edges.document(id);
if (!properties) {