Colin,
I find that local variables in XQuery only exist in the lexical scope they are
defined in, so:
let $foo := 10
let $nested-flwor :=
for $foo in ("a", "b", "c")
return $foo
return $foo
will return the outer "foo" which is 10.
However, a MarkLogic declared variable is like a Java thread local. It is
available for the entire request that was initiated by an XDMP or HTTP call. If
a library module has this declared variable:
/lib/my-library.xqy
module namespace some-lib namespace ...;
declare variable $cache-for-this-request-only := map:map();
[...]
any code that imports the module can share that map (update or read) but other
concurrent or subsequent requests will have their own copy.
Yours,
Damon
--
Damon Feldman
Sr. Principal Consultant, MarkLogic
From: [email protected]
[mailto:[email protected]] On Behalf Of David Lee
Sent: Friday, December 07, 2012 2:16 PM
To: colin mcenearney; MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] using maps - when to clear
Like any value in XQuery it goes away when it is out of scope ....
*unless* you set it to a system property ... then it lives for the life of the
host.
-----------------------------------------------------------------------------
David Lee
Lead Engineer
MarkLogic Corporation
[email protected]<mailto:[email protected]>
Phone: +1 812-482-5223
Cell: +1 812-630-7622
www.marklogic.com<http://www.marklogic.com/>
From:
[email protected]<mailto:[email protected]>
[mailto:[email protected]] On Behalf Of colin mcenearney
Sent: Friday, December 07, 2012 10:58 AM
To: [email protected]<mailto:[email protected]>
Subject: [MarkLogic Dev General] using maps - when to clear
Hi all,
When a map:map is created within a query is it automatically cleared when the
query ends? Or does it need to be explicitly cleared (map:clear) ?
Thanks,
Colin
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general