Get configuration options from the database.
(&self, key: &str)
| 584 | |
| 585 | /// Get configuration options from the database. |
| 586 | pub async fn get_raw_config(&self, key: &str) -> Result<Option<String>> { |
| 587 | let lock = self.config_cache.read().await; |
| 588 | let cached = lock.get(key).cloned(); |
| 589 | drop(lock); |
| 590 | |
| 591 | if let Some(c) = cached { |
| 592 | return Ok(c); |
| 593 | } |
| 594 | |
| 595 | let mut lock = self.config_cache.write().await; |
| 596 | let value = self |
| 597 | .query_get_value("SELECT value FROM config WHERE keyname=?", (key,)) |
| 598 | .await |
| 599 | .context(format!("failed to fetch raw config: {key}"))?; |
| 600 | lock.insert(key.to_string(), value.clone()); |
| 601 | drop(lock); |
| 602 | |
| 603 | Ok(value) |
| 604 | } |
| 605 | |
| 606 | /// Removes the `key`'s value from the cache. |
| 607 | pub(crate) async fn uncache_raw_config(&self, key: &str) { |
no test coverage detected