S3-FIFO caching

This commit is contained in:
mdecimus
2024-12-27 19:40:33 +01:00
parent 3530b6625f
commit f2b00ccd54
33 changed files with 631 additions and 383 deletions

View File

@@ -670,7 +670,7 @@ pub async fn test(params: &mut JMAPTest) {
.add_to_group(name, "sales@example.com")
.await;
}
server.inner.data.access_tokens.clear();
server.inner.cache.access_tokens.clear();
john_client.refresh_session().await.unwrap();
jane_client.refresh_session().await.unwrap();
bill_client.refresh_session().await.unwrap();
@@ -770,8 +770,8 @@ pub async fn test(params: &mut JMAPTest) {
.data
.remove_from_group("jdoe@example.com", "sales@example.com")
.await;
server.inner.data.http_auth_cache.clear();
server.inner.data.access_tokens.clear();
server.inner.cache.http_auth.clear();
server.inner.cache.access_tokens.clear();
assert_forbidden(
john_client
.set_default_account_id(sales_id.to_string())

View File

@@ -4,12 +4,7 @@
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
*/
use std::{
fmt::Debug,
path::PathBuf,
sync::Arc,
time::{Duration, Instant},
};
use std::{fmt::Debug, path::PathBuf, sync::Arc, time::Duration};
use base64::{
engine::general_purpose::{self, STANDARD},
@@ -26,7 +21,7 @@ use common::{
boot::build_ipc,
config::{ConfigManager, Patterns},
},
Core, Data, Inner, Server,
Caches, Core, Data, Inner, Server,
};
use enterprise::{insert_test_metrics, EnterpriseCore};
use hyper::{header::AUTHORIZATION, Method};
@@ -46,7 +41,7 @@ use store::{
IterateParams, Stores, ValueKey, SUBSPACE_PROPERTY,
};
use tokio::sync::watch;
use utils::{config::Config, map::ttl_dashmap::TtlMap, BlobHash};
use utils::{config::Config, BlobHash};
use webhooks::{spawn_mock_webhook_endpoint, MockWebhookEndpoint};
use crate::{
@@ -529,23 +524,18 @@ pub async fn emails_purge_tombstoned(server: &Server) {
.unwrap();
for account_id in account_ids {
let do_add = server
.inner
.data
.access_tokens
.get_with_ttl(&account_id)
.is_none();
let do_add = server.inner.cache.access_tokens.get(&account_id).is_none();
if do_add {
server.inner.data.access_tokens.insert_with_ttl(
server.inner.cache.access_tokens.insert(
account_id,
Arc::new(AccessToken::from_id(account_id)),
Instant::now() + Duration::from_secs(3600),
Duration::from_secs(3600),
);
}
server.emails_purge_tombstoned(account_id).await.unwrap();
if do_add {
server.inner.data.access_tokens.remove(&account_id);
server.inner.cache.access_tokens.remove(&account_id);
}
}
}
@@ -590,12 +580,14 @@ async fn init_jmap_tests(store_id: &str, delete_if_exists: bool) -> JMAPTest {
.await
.enable_enterprise();
let data = Data::parse(&mut config);
let cache = Caches::parse(&mut config);
let store = core.storage.data.clone();
let (ipc, mut ipc_rxs) = build_ipc();
let inner = Arc::new(Inner {
shared_core: core.into_shared(),
data,
ipc,
cache,
});
// Parse acceptors

View File

@@ -13,7 +13,7 @@ use std::{
};
use base64::{engine::general_purpose, Engine};
use common::{config::server::Listeners, listener::SessionData, Core, Data, Inner};
use common::{config::server::Listeners, listener::SessionData, Caches, Core, Data, Inner};
use ece::EcKeyComponents;
use hyper::{body, header::CONTENT_ENCODING, server::conn::http1, service::service_fn, StatusCode};
use hyper_util::rt::TokioIo;
@@ -104,6 +104,7 @@ pub async fn test(params: &mut JMAPTest) {
.await
.into_shared(),
data: Data::parse(&mut settings),
cache: Caches::parse(&mut settings),
..Default::default()
});
settings.errors.clear();