Strategies for "checkout" or explicit file locking
Sunday, 15 June 2014 · 2 messages · last reply 16 Jun 2014
AP
Alister Pillow15 Jun 2014 12:13 #
Hi all,
BaseX doesn’t appear to have explicit document-level access control (ownership and permissions). I understand that Write and Read locks are applied during queries - but these are not explicit and only apply during the course of the query.
I wonder what strategies other people use to lock a file for “editing”, or “checkout” a file so that only a single user has access (in a multi-user environment).
Does anyone manage more than a few users within one instance of BaseX? (e.g. more than 10)
Thanks,
Alister.
CG
Christian Grün16 Jun 2014 13:08 #
Dear Alister,
Quoted text · Alister Pillow · 1 line
> I wonder what strategies other people use to lock a file for “editing”, or “checkout” a file so that only a single user has access (in a multi-user environment).
We usually apply the XQuery locking options [1]: From all XQuery expressions that reference the same lock string, only one writing process will be run one at the same time. This can e. g. look as follows:
read.xq:
declare option query:read-lock "config";
file:read-text("config.xml")write.xq:
declare option query:write-lock "config";
file:write-text("config.xml", 'blablabla')Hope this helps,
Christian
[1] http://docs.basex.org/wiki/Transaction_Management#XQuery_Locking_Options
Written for BaseX 7.8. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery