(key: &str)
| 1595 | |
| 1596 | impl UserDefaultConfig { |
| 1597 | fn read(key: &str) -> String { |
| 1598 | let mut cfg = USER_DEFAULT_CONFIG.write().unwrap(); |
| 1599 | // we do so, because default config may changed in another process, but we don't sync it |
| 1600 | // but no need to read every time, give a small interval to avoid too many redundant read waste |
| 1601 | if cfg.1.elapsed() > Duration::from_secs(1) { |
| 1602 | *cfg = (Self::load(), Instant::now()); |
| 1603 | } |
| 1604 | cfg.0.get(key) |
| 1605 | } |
| 1606 | |
| 1607 | pub fn load() -> UserDefaultConfig { |
| 1608 | Config::load_::<UserDefaultConfig>("_default") |
no test coverage detected