Make the cache types compile time feature flags too, and make it more configurable!

This commit is contained in:
Zsombor Gegesy 2023-09-12 22:14:54 +02:00
parent 320f5f4720
commit 76795c43cc
7 changed files with 56 additions and 15 deletions

View file

@ -5,9 +5,7 @@
use mimalloc::MiMalloc;
use std::net::TcpListener;
use websurfx::{
cache::cacher::Cache, cache::redis_cacher::RedisCache, config::parser::Config, run,
};
use websurfx::{cache::cacher::Cache, config::parser::Config, run};
/// A dhat heap memory profiler
#[cfg(feature = "dhat-heap")]
@ -32,14 +30,8 @@ async fn main() -> std::io::Result<()> {
// Initialize the parsed config file.
let config = Config::parse(false).unwrap();
let cache = match &config.redis_url {
Some(url) => Cache::new(
RedisCache::new(url, 5)
.await
.expect("Redis cache configured"),
),
None => Cache::new_in_memory(),
};
let cache = Cache::build(&config).await;
log::info!(
"started server on port {} and IP {}",