Function set_meta_value

Source
pub async fn set_meta_value(
    pool: &Pool<MySql>,
    key: &str,
    value: &str,
) -> Result<()>
Expand description

Sets a metadata value for a specific key.

This function stores a key-value pair in the metadata table. If the key already exists, its value is updated. The operation is performed atomically within a transaction and is protected by a mutex to prevent concurrent modifications.

§Arguments

  • pool - Database connection pool for executing the query
  • key - The unique key to associate with the value
  • value - The value to store

§Returns

  • Ok(()) - Successfully stored the key-value pair
  • Err(anyhow::Error) - Failed to store the key-value pair

§Concurrency

This function acquires the global metadata mutex to ensure thread safety when multiple threads attempt to modify the same key.

§Transaction Handling

This function uses a database transaction that:

  1. Deletes any existing entries with the same key
  2. Inserts the new key-value pair

If any part of this operation fails, the entire transaction is rolled back, preserving data consistency.