Delay set cache after response, make cache static
Uses `tokio::spawn` to delay updating the cache while the server responds to the request. Because `tokio::spawn` can run on another thread, references need to be static, so I initialized the cache in `lazy_static`.
This commit is contained in:
@@ -9,6 +9,10 @@ mod cached_response;
|
||||
pub use cache::Cache;
|
||||
pub use cached_response::CachedResponse;
|
||||
|
||||
lazy_static! {
|
||||
pub static ref CACHES: Caches = Caches::initialize();
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Caches {
|
||||
pub owner_ids_by_api_key: Cache<Uuid, i32>,
|
||||
|
||||
Reference in New Issue
Block a user