Hello Christian !

Yes, a -c option for the basexhttp would help, as mentioned earlier, for 
example creating a shared mainmem collection.

Best regards,
Fabrice

-----Message d'origine-----
De : basex-talk-boun...@mailman.uni-konstanz.de 
[mailto:basex-talk-boun...@mailman.uni-konstanz.de] De la part de Christian Grün
Envoyé : lundi 18 septembre 2017 16:20
À : Kendall Shaw; coach3pete
Cc : basex-talk@mailman.uni-konstanz.de
Objet : Re: [basex-talk] Server Variables, cached vars, etc

Hi Erik,

I think that Xavier-Laurent, Marco, Fabrice and Kendall have already given 
excellent feedback.

In our own projects, we store all global data in databases, or in local 
configuration files. One advantage is that this data requires no initialization 
and will automatically be available after a restart.

I don’t know anything about »server variables« in MarkLogic so far, so
@Erik: feel free to pass me on a link to the documentation, and I can check if 
a similar solution could make sense for BaseX.

Talking about the start script server option: The basexserver command comes 
with a -c flag, which allows you run initial commands [1]. We could add such a 
flag for basexhttp, or even allow an initial input for both startup commands 
(similar to basex/basexclient). Would this be helpful for some of you reading 
this? Quite obviously, this requires BaseX to be run via these scripts (it 
wouldn’t have any effect if BaseX is deployed as servlet).

Cheers,
Christian

[1] http://docs.basex.org/wiki/Command-Line_Options#Server



On Sun, Sep 10, 2017 at 1:56 AM, Kendall Shaw <kendall.s...@workday.com> wrote:
> The servlet could populate your singleton just once upon startup, or 
> run xquery etc. The load-on-startup configuration means that the 
> servlet is initialized after basex has been loaded. So, if you restart 
> jetty or whatever web server/web container you are using basex 
> restarts and then your servlet’s init method is invoked.
>
>
>
> Kendall
>
>
>
> From: Erik Peterson <e...@ardec.com>
> Date: Saturday, September 9, 2017 at 4:16 AM
> To: Kendall Shaw <kendall.s...@workday.com>
> Cc: "basex-talk@mailman.uni-konstanz.de"
> <basex-talk@mailman.uni-konstanz.de>
>
>
> Subject: Re: [basex-talk] Server Variables, cached vars, etc
>
>
>
> Thanks Kendal for your reply. What would be the advantage of creating 
> a servlet over a singleton class to do the same thing?
>
>
>
> On Fri, Sep 8, 2017 at 11:12 AM, Kendall Shaw 
> <kendall.s...@workday.com>
> wrote:
>
> I thought it might be useful to mention advice I was given about 
> startup
> hooks:
>
>
>
>> From: "Kirsten, Dirk" dirk.kirs...@senacor.com
>
> ,,,
>
>> there is currently no way to do this using BaseX itself. But I also 
>> don’t think that should be the job of BaseX. Instead you can write a 
>> servlet and deploy it using Tomcat which runs some Java application, 
>> e.g. which could trigger some BaseXX command. See 
>> http://crunchify.com/how-to-run-java-program-automatically-on-tomcat-
>> startup/
>> for an example how to do this.
>
>
>
> I switched from using a cron job, to doing this in order to schedule jobs.
> I have very simple servlet that is configured with 
> <load-on-startup>2</load-on-startup> (basex has load-on-startup 2). It 
> runs a shell script which schedules the jobs, soon after basex is loaded.
>
>
>
> Kendall
>
>
>
> From: <basex-talk-boun...@mailman.uni-konstanz.de> on behalf of Erik 
> Peterson <e...@ardec.com>
> Date: Tuesday, September 5, 2017 at 7:02 AM
> To: Fabrice ETANCHAUD <fetanch...@pch.cerfrance.fr>, 
> "basex-talk@mailman.uni-konstanz.de" 
> <basex-talk@mailman.uni-konstanz.de>
> Subject: Re: [basex-talk] Server Variables, cached vars, etc
>
>
>
> 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 
> <fetanch...@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-boun...@mailman.uni-konstanz.de
> [mailto:basex-talk-boun...@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 | e...@ardec.com
>
>
>
>
>
> --
>
> Erik Peterson
>
> President, Ardec LLC
>
> 281-804-9023 | e...@ardec.com

Reply via email to