.TH "md_doc_help_elektra-classes" 3elektra "Sun May 29 2016" "Version 0.8.14" "Elektra" \" -*- nroff -*- .ad l .nh .SH NAME md_doc_help_elektra-classes \- elektra classes(7) -- introduction in Elektra's classes This overview complements the introduction in \fCthe API documentation\fP\&. .PP A \fCKey\fP consists of a name, a value and metadata\&. It is the atomic unit in the key database\&. Its main purpose is that it can be serialised to be written out to permanent storage\&. It can be added to several aggregates using reference counting\&. Putting \fCKey\fP objects into other data structures of supported programming languages presents no problem\&. .PP .SS "KeySet" .PP The central data structure in Elektra is a \fCKeySet\fP\&. It aggregates \fCKey\fP objects in order to describe configuration in an easy but complete way\&. As the name ''set'' already implies every \fCKey\fP in a \fCKeySet\fP has a unique name\&. A user can iterate over the \fCKey\fP objects of a \fCKeySet\fP\&. \fCKeySet\fP sorts the keys by their names\&. This yields a deterministic order advantage\&. So, independent of the appending sequence and, in particular, the number of fetches and updates, \fCKeySet\fP guarantees the same order of the \fCKey\fP objects\&. Some configuration storage systems need this property, because they cannot remember a specific order\&. On the other hand, any particular order can easily be introduced (See \fBorder\fP)\&. .PP On the one side backends generate or store a \fCKeySet\fP object and, on the other side, elektrified applications receive and send a \fCKeySet\fP object\&. Both sides, as well as the core in between, have the possibility to iterate, update, modify, extend and reduce the key set\&. Appending of new or existing \fCKey\fP objects extends the key set\&. Otherwise it can be reduced if keys are popped out\&. The \fCKey\fP object becomes independent from the \fCKeySet\fP afterwards\&. The user can still change such a key or append it into another key set\&. The affiliation to a key set is not exclusive\&. .PP Every key in a \fCKeySet\fP object has a unique name\&. Appending \fCKey\fP objects with the same name will override the already existing \fCKey\fP object\&. .PP .SS "KDB" .PP While objects of \fCKey\fP and \fCKeySet\fP only reside in memory, Elektra's third class \fCKDB\fP actually provides access to the global key database\&. \fCKDB\fP, an abbreviation of key database, is responsible for actually storing and receiving configuration\&. \fCKeySet\fP represents the configuration when communicating with \fCKDB\fP\&. The typical elektrified application collects its configuration by one or many calls of \fC\fBkdbGet()\fP\fP\&. As soon as the program finishes its work with the \fCKeySet\fP, \fC\fBkdbSet()\fP\fP is in charge of writing all changes back to the key database\&. .PP This technique has some advantages\&. First, applications have full control over modifying \fCKey\fP and \fCKeySet\fP objects without touching the key database\&. Second, the decision how many \fCKeySet\fP objects the application administrates is left to the application\&. It can choose how to split up the \fCKeySet\fP objects\&. The main reason for this technique is that for backend development the same data structure is used, and as we will see, the borderline between application and backend development becomes blurred\&. .PP The application adapts the configuration between \fC\fBkdbGet()\fP\fP and \fC\fBkdbSet()\fP\fP in memory\&. The modifications are not only faster, they also allow large atomic configuration upgrades, robust merging of settings and handling of complicated inter-relationships between keys without problematic interstages\&. Elektrified applications, however, should be aware of conflicts\&. It can happen that the key database is changed while working with a \fCKeySet\fP\&. Then, attempts to use \fC\fBkdbSet()\fP\fP lead to a conflict\&. \fCKDB\fP detects such situations gracefully and lets the application decide which configuration should be used\&. .PP For details and background \fBread more about elektra data structures\fP\&. For further information see \fCthe API documentation\fP\&.