fix: use CachedSecret struct instead of tuples in sync methods
Some checks failed
BotServer CI/CD / build (push) Failing after 2s
Some checks failed
BotServer CI/CD / build (push) Failing after 2s
This commit is contained in:
parent
9383cf0e3a
commit
60dc273681
2 changed files with 8 additions and 3 deletions
|
|
@ -232,6 +232,8 @@ rust-embed = { workspace = true, optional = true }
|
|||
mockito = { workspace = true }
|
||||
tempfile = { workspace = true }
|
||||
bigdecimal = { workspace = true }
|
||||
|
||||
[dependencies]
|
||||
ureq = { version = "2", features = ["json"] }
|
||||
|
||||
[dev-dependencies]
|
||||
|
|
|
|||
|
|
@ -929,8 +929,8 @@ impl SecretsManager {
|
|||
fn get_cached_sync(&self, path: &str) -> Option<HashMap<String, String>> {
|
||||
let cache = self.cache.read().ok()?;
|
||||
let entry = cache.get(path)?;
|
||||
if entry.1.elapsed() < std::time::Duration::from_secs(self.cache_ttl) {
|
||||
Some(entry.0.clone())
|
||||
if entry.expires_at.elapsed() < std::time::Duration::from_secs(self.cache_ttl) {
|
||||
Some(entry.data.clone())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
|
@ -939,7 +939,10 @@ impl SecretsManager {
|
|||
fn cache_secret_sync(&self, path: &str, data: HashMap<String, String>) {
|
||||
if self.cache_ttl > 0 {
|
||||
if let Ok(mut cache) = self.cache.write() {
|
||||
cache.insert(path.to_string(), (data, std::time::Instant::now()));
|
||||
cache.insert(path.to_string(), CachedSecret {
|
||||
data,
|
||||
expires_at: std::time::Instant::now(),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue