Persistence Service

The Persistence Service enables you to store in key-value pairs the information in Kanzi Connect Client applications and local and remote Kanzi Connect services and preserve that information through restarts of a Kanzi Connect Client application.

You can use the Persistence Service in these ways:

  • Use the persistent runtime data. You can configure the runtime data to use the Persistence Service to store the data values. For example, the System Service uses the Persistence Service make some of its runtime data values persistent. The Control Panel example uses and modifies the runtime data of the System Service, such as temperature, so when the user modifies these values in the client application, the Persistence Service stores these values and makes them available even after you restart either the server or the client application.

    To configure a runtime data value to be persistent a value for runtime data of a service, in the xml file that defines the interface of that service add to the data value that you want to persist persistent="1". After you generate the service code, the runtime data handles the persistence of all such values.

    ../_images/persistence-use-case-1.png
  • Use the Persistence Service through the C++ API. In a service you can use the setting factory to instantiate a local setting and use this setting to access the Persistence Service and store the setting value to disk. For example, the Custom service tutorial where you create a service, uses this approach and runs the service in the same process with the Kanzi Connect Server, so the factory automatically selects the local setting.

    You use the setting factory to abstract the connection between the setting and the persistence service. If you run a service as a remote service in a separate process, the setting factory instantiates the remote setting instances and uses the defined connection adapters for communication with the Persistence Service. The remote service does not need to know about which type of setting is being instantiated. See Tutorial: Create a custom Kanzi Connect service.

    ../_images/persistence-use-case-2.png
  • Use the Persistence Service in a Kanzi Connect client application. In a client application you can use a trigger which executes the Persistence Service action writeSettingValue to send the value you set in the action to the Kanzi Connect Server. You identify the setting to which the Persistence Service writes using a unique key and include both the key and the value in the writeSettingValue action. For example, you can set a trigger to send a value of a property to the Persistence Service whenever that value changes. See Tutorial: Create a custom Kanzi Connect service.

    ../_images/persistence-use-case-3.png

Interface definition

The interface definition XML file for the Persistence Service is stored in the <KanziConnectInstallation>/SDK/sources/connect/core_services/persistence_service/interface/persistence_interface.xml.

Fully qualified name for the Persistence Service is Connect.CoreService.Persistence.

Supported platforms

This service is supported on all platforms that Kanzi Connect supports.