Bump duration for actor cache to 30 minutes

This commit is contained in:
asonix 2020-04-01 15:47:18 -05:00
parent a52a32db8d
commit 69ec2baf79

View file

@ -6,7 +6,7 @@ use tokio::sync::RwLock;
use ttl_cache::TtlCache; use ttl_cache::TtlCache;
use uuid::Uuid; use uuid::Uuid;
const REFETCH_DURATION: u64 = 60 * 2; const REFETCH_DURATION: Duration = Duration::from_secs(60 * 30);
#[derive(Clone)] #[derive(Clone)]
pub struct ActorCache { pub struct ActorCache {
@ -38,11 +38,10 @@ impl ActorCache {
} }
if let Some(actor) = self.lookup(id).await? { if let Some(actor) = self.lookup(id).await? {
self.cache.write().await.insert( self.cache
id.clone(), .write()
actor.clone(), .await
Duration::from_secs(REFETCH_DURATION), .insert(id.clone(), actor.clone(), REFETCH_DURATION);
);
return Ok(actor); return Ok(actor);
} }
@ -67,11 +66,10 @@ impl ActorCache {
inbox, inbox,
}; };
self.cache.write().await.insert( self.cache
id.clone(), .write()
actor.clone(), .await
Duration::from_secs(REFETCH_DURATION), .insert(id.clone(), actor.clone(), REFETCH_DURATION);
);
self.update(id, &actor.public_key, &actor.public_key_id) self.update(id, &actor.public_key, &actor.public_key_id)
.await?; .await?;