A problem with that is that it evaluates the variable each time. If you need it 
to only evaluate once (expensive operation), something else needs to be done. I 
would like to know an answer to this so that I can schedule jobs on start up 
without involving processes external to basex.

From: <basex-talk-boun...@mailman.uni-konstanz.de> on behalf of Xavier-Laurent 
SALVADOR <xavierlaurent.salva...@gmail.com>
Date: Monday, September 4, 2017 at 11:42 PM
To: Erik Peterson <e...@ardec.com>
Cc: BaseX <basex-talk@mailman.uni-konstanz.de>
Subject: Re: [basex-talk] Server Variables, cached vars, etc

Hi,

do you mean something like a repo variable ?

If you define a module name in your repo:

 1-      module namespace myNs = 
'http://www.xxxxx.fr/xxxx-repo’<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.xxxxx.fr_xxxx-2Drepo-25E2-2580-2599&d=DwMFaQ&c=DS6PUFBBr_KiLo7Sjt3ljp5jaW5k2i9ijVXllEdOozc&r=JgwnBEpN1c-DDmq-Up2QMq9rrGyfWK0KtSpT7dxRglA&m=6BbM4k_uDRdhjURAbaUe8SgS19qfgxyIM03BQbY2xzk&s=vnUoDRkXSxl-NAs4wmOr8q2saq5Y9K0_k6l71w-jrrM&e=>;

You can define in your repo a new variable :

 1-    declare variable $myNs:testid :=  
db:open(‘xxxxx')/utilisateurs/entry/sessions/session/id=session:id();

Then import your module in your restxq:

  1-   import module namespace isi = 
'http://www.isilex.fr/isi-repo’<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.isilex.fr_isi-2Drepo-25E2-2580-2599&d=DwMFaQ&c=DS6PUFBBr_KiLo7Sjt3ljp5jaW5k2i9ijVXllEdOozc&r=JgwnBEpN1c-DDmq-Up2QMq9rrGyfWK0KtSpT7dxRglA&m=6BbM4k_uDRdhjURAbaUe8SgS19qfgxyIM03BQbY2xzk&s=7iT9husSt3pxwCXxx8Kf7Sf1KKDDurqvyhDHERP1p2g&e=>;

And access your variables:

  1-    $myNs:testid

More here: 
http://docs.basex.org/wiki/XQuery_3.0#External_Variables<https://urldefense.proofpoint.com/v2/url?u=http-3A__docs.basex.org_wiki_XQuery-5F3.0-23External-5FVariables&d=DwMFaQ&c=DS6PUFBBr_KiLo7Sjt3ljp5jaW5k2i9ijVXllEdOozc&r=JgwnBEpN1c-DDmq-Up2QMq9rrGyfWK0KtSpT7dxRglA&m=6BbM4k_uDRdhjURAbaUe8SgS19qfgxyIM03BQbY2xzk&s=tfVbcjLW6lGgTfWHzfgWtKLPja7kdFONHW74KF_CdiA&e=>

Sorry If I’m wrong and didn’t understand,

XLS
Le 5 sept. 2017 à 01:37, Erik Peterson <e...@ardec.com<mailto:e...@ardec.com>> 
a écrit :

How can I create a variable that is evaluated only once but accessed across 
many RestXQ requests and sessions. I'm trying to cache data that comes from an 
integration with an expensive operation. Does BaseX support something similar 
to server variables like Mark Logic?


Reply via email to