chore: remove orphan test_cache.rs and unused memmap2 dependency

This commit is contained in:
Dionisio
2026-02-15 21:20:20 +01:00
parent 1527223d62
commit 6e1b77f244
3 changed files with 0 additions and 73 deletions
Generated
-10
View File
@@ -1551,15 +1551,6 @@ version = "2.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273"
[[package]]
name = "memmap2"
version = "0.9.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "744133e4a0e0a658e1374cf3bf8e415c4052a15a111acd372764c55b4177d490"
dependencies = [
"libc",
]
[[package]]
name = "mime"
version = "0.3.17"
@@ -1772,7 +1763,6 @@ dependencies = [
"jsonwebtoken",
"lru",
"md5",
"memmap2",
"mime_guess",
"mockall",
"moka",
-1
View File
@@ -39,7 +39,6 @@ quick-xml = "0.39.0"
dotenvy = "0.15.7"
lru = "0.16.3"
moka = { version = "0.12", features = ["future"] }
memmap2 = "0.9"
http-range-header = "0.4"
image = { version = "0.25", default-features = false, features = ["jpeg", "png", "gif", "webp"] }
md5 = "0.8.0"
-62
View File
@@ -1,62 +0,0 @@
use super::cache::{HttpCache, HttpCacheLayer, start_cache_cleanup_task};
use axum::{
routing::get,
Router,
response::IntoResponse,
Json,
extract::State,
};
use serde::{Serialize, Deserialize};
use std::sync::Arc;
use std::time::Duration;
use std::net::SocketAddr;
#[derive(Clone, Debug, Serialize, Deserialize)]
struct TestResponse {
message: &'static str,
timestamp: u64,
}
// Test handler for a simple GET endpoint
async fn test_handler() -> impl IntoResponse {
// Create a simple response with a timestamp
let timestamp = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.unwrap()
.as_secs();
// Simulate some processing time
tokio::time::sleep(Duration::from_millis(50)).await;
let response = TestResponse {
message: "Hello, this response is cacheable!",
timestamp,
};
// Log the response generation
tracing::info!("Generated fresh response with timestamp: {}", timestamp);
Json(response)
}
// Run a test server with HTTP caching enabled
pub async fn run_test_server() {
// Initialize HTTP cache with 10 seconds TTL
let http_cache = HttpCache::with_max_age(10);
// Start the cleanup task
start_cache_cleanup_task(http_cache.clone());
// Create a test router with the cache middleware
let app = Router::new()
.route("/test", get(test_handler))
.layer(HttpCacheLayer::new(http_cache));
// Bind to a test port
let addr = SocketAddr::from(([127, 0, 0, 1], 8086));
tracing::info!("HTTP Cache test server listening on {}", addr);
// Start the server
let listener = tokio::net::TcpListener::bind(addr).await.unwrap();
axum::serve(listener, app).await.unwrap();
}