Neo4j PHP获取Wirte锁 [英] Neo4j PHP Acquire wirte lock
问题描述
陷入困境,
谁能告诉我,我怎么能通过密码获得写锁. 注意:我将使用REST API,因此我的密码将在php中使用.
Well can anyone tell me , how can i acquire write lock through cypher. Note : I will use REST APIs , So my cypher would in php.
场景:
我正在使用Neo4j REST服务器和PHP来访问它.
I am using Neo4j REST server and PHP to access it.
现在我已经创建了一个节点,例如"counter-node",它会生成新的用户ID.逻辑是在前面的值上加1.
Now i have created a node say 'counter-node' which generates new user id. Logic is just add 1 to previous value.
现在,如果两个用户同时到来,则第一个用户在将计数器节点"值BUT更新为1之前先读取了该值,而第二个用户则读取了它.因此,反向节点"中的值与预期不符.
Now If two users are coming simultaneously then first user read 'counter-node' value BUT before it can update it to 1 , second user read it . Thus value in 'counter-node' is not as expected.
任何帮助
推荐答案
流行的 Neo4j的APOC 插件具有一系列明确的锁定过程,可以通过Cypher调用这些过程,例如call apoc.lock.nodes([nodes])
The popular APOC plugin for Neo4j has a selection of explicit Locking procedures that can be called via Cypher such as call apoc.lock.nodes([nodes])
有关详细信息,请参见 neo4j-contrib.github.io/neo4j-apoc -procedures/#_ locking
Learn more at neo4j-contrib.github.io/neo4j-apoc-procedures/#_locking
注意:据我所知,此功能在Cypher中并不存在,因此APOC可能是您最好的选择.
这篇关于Neo4j PHP获取Wirte锁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!