From: Jean-Paul R. <re...@gm...> - 2020-12-20 14:13:53
|
>xquery has no static Indeed. But as I tried to describe in my use case, I use this method for assigning values which are *in effect* static across my application (*not static in programming terms*). For example: let $globalvar:datastring := "/db/apps/myapp/data" But I would not do this: let $globalvar:somedoc := doc( "/db/apps/myapp/data/mydoc.xml") *unless* I was sure that the underlying document was not going to be changed elsewhere at the moment the variable was being used. I use this method for config files that rarely change. (For me, this is an issue of concurrent changes to a file, not really a question of processing cost.) The above may not be useful practice for your context, but in my applications it is as effective as the cache... Cheers, JPR On Sun, Dec 20, 2020 at 2:23 PM Eduard Drenth <ed...@fr...> wrote: > Thanks, but, xquery has no static. And if I do > > declare variable $x := mod:func(); > > either or not in an imported module, > > mod:func() gets executed with every request I suspect, but correct me if I > am wrong. > > Regards, Eduard > > -----Original Message----- > *From*: Jean-Paul Rehr <re...@gm... > <Jean-Paul%20Rehr%20%3cr...@gm...%3e>> > *To*: Eduard Drenth <ed...@fr... > <Eduard%20Drenth%20%3ce...@fr...%3e>> > *Cc*: exi...@li... <exi...@li... > <%22e...@li...%22%20%3ce...@li...%3e> > > > *Subject*: Re: [Exist-open] static variables? > *Date*: Sun, 20 Dec 2020 13:03:35 +0100 > > I accomplish this with a module that just has my "global variables" for > use across the application. This "global variable" module is literally only > populated with static variables which I can then declare and import as > needed in my queries. I keep a lot of static configuration data and > reusable path strings in them..... > > On Sun, Dec 20, 2020 at 12:45 PM Eduard Drenth <ed...@fr...> > wrote: > > Dear all, > > For performance reasons I want to be able to work with static variables. > My data in exist is readonly. > > I get the impression that variables are evaluated on every request > normally, so if I do: > > declare variable > > $ > > teidictjson > > : > > data := .... > > > this variable is request scoped. Can I somehow make that static or > application scoped? Or is the cache module the only way? > > Bye, Eduard > > > -- > > > Eduard Drenth, Software Architekt > > ed...@fr... > > Doelestrjitte 8 > 8911 DX Ljouwert > +31 58 234 30 47 > +31 62 094 34 28 (privé) > > skype: eduarddrenth > https://github.com/eduarddrenth > frisian.eu > gpg: https://pgp.surfnet.nl/pks/lookup?search=eduarddrenth > > > Op freed bin ik thús/wurkje ik minder > > > > _______________________________________________ > Exist-open mailing list > Exi...@li... > https://lists.sourceforge.net/lists/listinfo/exist-open > > -- > > Eduard Drenth, Software Architekt > > ed...@fr... > > Doelestrjitte 8 > 8911 DX Ljouwert > +31 58 234 30 47 > +31 62 094 34 28 (privé) > > skype: eduarddrenth > https://github.com/eduarddrenth > frisian.eu > gpg: https://pgp.surfnet.nl/pks/lookup?search=eduarddrenth > > > Op freed bin ik thús/wurkje ik minder > > > > |