PebbleOS
Loading...
Searching...
No Matches
Functions
Persist

Per-app persistent key-value stores. More...

Functions

void persist_service_init (void)
 Initialize the persist service.
 
size_t persist_service_get_max_size (void)
 Get the per-app storage capacity.
 
SettingsFile * persist_service_lock_and_get_store (const Uuid *uuid)
 Lock the persist service and get the store of an app.
 
void persist_service_unlock_store (SettingsFile *store)
 Unlock a store obtained with persist_service_lock_and_get_store().
 
void persist_service_client_open (const Uuid *uuid)
 Register a process using the store of an app.
 
void persist_service_client_close (const Uuid *uuid)
 Unregister a process using the store of an app.
 
status_t persist_service_delete_file (const Uuid *uuid)
 Delete the persist file of an app.
 

Detailed Description

Per-app persistent key-value stores.

A store is a SettingsFile named after the app UUID. An app and its worker share one store, file handle and SettingsFile state. The file is created lazily on first access.

The SettingsFile is not reentrant: access it only between persist_service_lock_and_get_store() and persist_service_unlock_store().

status_t rv = settings_file_set(file, &key, sizeof(key), &value, sizeof(value));
void persist_service_unlock_store(SettingsFile *store)
Unlock a store obtained with persist_service_lock_and_get_store().
SettingsFile * persist_service_lock_and_get_store(const Uuid *uuid)
Lock the persist service and get the store of an app.
Open settings file.
Definition settings_file.h:51
status_t settings_file_set(SettingsFile *file, const void *key, size_t key_len, const void *val, size_t val_len)
Write a value, timestamped with the current time.

Function Documentation

◆ persist_service_client_close()

void persist_service_client_close ( const Uuid *  uuid)

Unregister a process using the store of an app.

Called after the process exits. The store is closed and released when its last user leaves.

Parameters
uuidApp UUID.

◆ persist_service_client_open()

void persist_service_client_open ( const Uuid *  uuid)

Register a process using the store of an app.

Called during process startup.

Parameters
uuidApp UUID.

◆ persist_service_delete_file()

status_t persist_service_delete_file ( const Uuid *  uuid)

Delete the persist file of an app.

Parameters
uuidApp UUID.
Returns
Status of the file removal.

◆ persist_service_get_max_size()

size_t persist_service_get_max_size ( void  )

Get the per-app storage capacity.

Returns
Capacity in bytes.

◆ persist_service_init()

void persist_service_init ( void  )

Initialize the persist service.

Called once at boot. Migrates and cleans up files in legacy naming schemes.

◆ persist_service_lock_and_get_store()

SettingsFile * persist_service_lock_and_get_store ( const Uuid *  uuid)

Lock the persist service and get the store of an app.

Opens or creates the file on first use. The app must have been opened with persist_service_client_open(). The lock is held until persist_service_unlock_store().

Parameters
uuidApp UUID.
Returns
Store of the app.

◆ persist_service_unlock_store()

void persist_service_unlock_store ( SettingsFile *  store)

Unlock a store obtained with persist_service_lock_and_get_store().

Parameters
storeStore to unlock.