Changes

Jump to navigation Jump to search
114 bytes removed ,  18:37, 1 December 2023
m
Text replacement - "</syntaxhighlight>" to "</pre>"
In addition, custom stores can be read and written. Custom stores have filenames with the pattern {{Code|store-NAME.basex}}. The implicit write of the standard store at shutdown time will be disabled if a custom store is used.
Functions of this module are non-deterministic nondeterministic and side-effecting: Updates will immediately be visible, and a repeated call of the same function may yield different results if the contents of the store have changed.
=Conventions=
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|<pre>store:get|( $key as xs:string|) as item()*}}<br/ pre>
|- valign="top"
|'''Summary'''
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|<pre>store:put|( $key as xs:string, $value as item()*|) as empty-sequence()}}<br/ pre>
|- valign="top"
|'''Summary'''
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|<pre>store:get-or-put|( $key as xs:string, $put as function(*)) as item()*|item()*}}<br/ pre>
|- valign="top"
|'''Summary'''
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|<pre>store:remove|( $key as xs:string|) as empty-sequence()}}<br/ pre>
|- valign="top"
|'''Summary'''
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|<pre>store:keys||() as xs:string*}}</pre>
|- valign="top"
|'''Summary'''
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|<pre>store:clear||() as empty-sequence()}}<br/ pre>
|- valign="top"
|'''Summary'''
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|store:read||empty-sequence()}}<br/ pre>{{Func|store:read|( $name as xs:string|? := ()) as empty-sequence()}}</pre>
|- valign="top"
|'''Summary'''
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|store:write||empty-sequence()}}<br/ pre>{{Func|store:write|( $name as xs:string|? := ()) as empty-sequence()}}</pre>
|- valign="top"
|'''Summary'''
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|<pre>store:list||() as xs:string*}}</pre>
|- valign="top"
|'''Summary'''
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|<pre>store:delete|( $name as xs:string|) as empty-sequence()}}</pre>
|- valign="top"
|'''Summary'''
'''Use Case 1: Create/update a system configuration in a running BaseX server instance:
<syntaxhighlight pre lang="'xquery"'>
(: store an integer :)
store:put('version', 1),
(: serialize configuration to disk :)
store:write()
</syntaxhighlightpre>
The configuration can be requested by further operations, e.g. a client request:
<syntaxhighlight pre lang="'xquery"'>
store:get('version')
</syntaxhighlightpre>
The store will still be available if BaseX is restarted until it is cleared.
'''Use Case 2: Create index for fast lookup operations in the GUI:
<syntaxhighlight pre lang="'xquery"'>
let $map := map:merge(
for $country in db:get('factbook')//country
)
return store:put('religions', $map)
</syntaxhighlightpre>
A subsequent query can be used to access its contents:
<syntaxhighlight pre lang="'xquery"'>
store:get('religions')?Buddhism
</syntaxhighlightpre>
Note that the store will eventually be written to disk unless it is invalidated before closing the GUI.
Bureaucrats, editor, reviewer, Administrators
13,554

edits

Navigation menu