Skip to content Skip to sidebar Skip to footer

Is Py2neo Caching Burning Me?

I am running this code: c = ''' match(r:XX) optional match(r)-[]-(m) with count(m) as mc, r match(x) return count(x) as all, r, mc ''' (snip!) while

Solution 1:

Interesting enough, py2neo 'remembers' the node when you return the node:

MATCH (n:Node) RETURN n

But when you return individual properties, they will always be updated:

MATCH (n:Node) RETURN n.value

For your query that means you have to run my_node.pull() when you return the same node twice in a while loop:

while True:
    q = "MATCH (n:Node) RETURN n"
    result = graph.cypher.execute(q)
    my_node = result[0][0]
    my_node.pull()
    print(my_node)

You can also move everything besides the pull() out of the loop:

q = "MATCH (n:Node) RETURN n"
result = graph.cypher.execute(q)
my_node = result[0][0]

while True:
    my_node.pull()
    print(my_node)

Here is a minimal example describing the behaviour: http://paste.ubuntu.com/14015568/

I'm not really sure why py2neo does not return updated node data when you run a new query.

Solution 2:

What do you mean when you say the node's attributes? Do you mean properties? Or are relationships added/removed as well?

What do you expect to get back in r? Judging from the query, unless the daemon you mention is adding/removing the :XX label to/from nodes, it'll return exactly the same nodes always.

Post a Comment for "Is Py2neo Caching Burning Me?"