Thank you all for your replys.  It looks like a main memory database is the best "built in" option.  However, I have created Jar file  to drop him/lib with a Java Singleton object...holding a map.  That should be  accessible across requests and sessions.   The question is how to populate this just once upon start up?  Perhaps I could do a job that would do that?  Also I could memoize the variables in a global script.  That way the expensive operation is only run the first time it is needed. 

Any other suggestions welcome.  Recommend that a standard built-in feature  be added to handle these scenarios. 

On Tue, Sep 5, 2017 at 1:33 AM Fabrice ETANCHAUD <fetanchaud@pch.cerfrance.fr> wrote:
To be confirmed : there is no 'start script' server option.
I do manually create and populate the mainmem db in the dba query interface.

Best regards,
Fabrice

-----Message d'origine-----
De : Fabrice ETANCHAUD
Envoyé : mardi 5 septembre 2017 09:29
À : 'Marco Lettere'; basex-talk@mailman.uni-konstanz.de
Objet : RE: [basex-talk] Server Variables, cached vars, etc

Hi all,

Another solution is to share a main memory database, that behaves like a memory cache.
In Client/Server mode, any main memory created by one client is available to all the other ones.

Best regards,
Fabrice


-----Message d'origine-----
De : basex-talk-bounces@mailman.uni-konstanz.de [mailto:basex-talk-bounces@mailman.uni-konstanz.de] De la part de Marco Lettere Envoyé : mardi 5 septembre 2017 09:14 À : basex-talk@mailman.uni-konstanz.de
Objet : Re: [basex-talk] Server Variables, cached vars, etc

On 05/09/2017 01:37, Erik Peterson wrote:
> 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?

Hi Erik,

AFAIK you have the following possibilities to keep a variable live accross multiple RestXQ calls:

1) Use session http://docs.basex.org/wiki/Session_Module

2) Use a database which is builtin in BaseX and is very lightweight.
Especially if your data is serializable to XML you could benefit also from indexes to speed up access to your cached objects.

3) Use the file system.

Hope this helps [cit] ;-)

Marco.

--
Erik Peterson
President, Ardec LLC
281-804-9023 | ep@ardec.com