remove logging

This commit is contained in:
Evan Almloff committed 2023-06-21 18:51:40 -07:00
1 parent 3a690877d1
commit 3d41dd95c9
2 files changed
+12 -5

No files matched your search

@@ -2,6 +2,7 @@
use dioxus::prelude::*;
use dioxus_router::prelude::*;
use dioxus_router::ssr::{DefaultRenderer, IncrementalRendererConfig};
fn main() {
@@ -21,7 +22,6 @@ fn main() {
.to_string(),
})
.static_dir("./static")
.memory_cache_limit(5)
.build();
renderer.pre_cache_static::<Route>();
+11 -4
View File
@@ -132,8 +132,16 @@ impl<R: RenderHTML> IncrementalRenderer<R> {
let file = std::fs::File::create(dbg!(file_path)).unwrap();
let mut file = std::io::BufWriter::new(file);
file.write_all(html.as_bytes()).unwrap();
self.add_to_memory_cache(route, html);
}
fn add_to_memory_cache<K: AsRef<str> + ToString, V: ToString>(&mut self, route: K, html: V) {
if let Some(cache) = self.memory_cache.as_mut() {
cache.put(route, html);
if cache.contains(route.as_ref()) {
cache.promote(route.as_ref())
} else {
cache.put(route.to_string(), html.to_string());
}
}
}
@@ -143,15 +151,14 @@ impl<R: RenderHTML> IncrementalRenderer<R> {
.as_mut()
.and_then(|cache| cache.get(&route).cloned())
{
println!("memory cache hit");
Some(cache_hit)
} else {
let file_path = self.route_as_path(&route);
if let Ok(file) = dbg!(std::fs::File::open(file_path)) {
if let Ok(file) = std::fs::File::open(file_path) {
let mut file = std::io::BufReader::new(file);
let mut html = String::new();
file.read_to_string(&mut html).ok()?;
println!("file cache hit");
self.add_to_memory_cache(route, html.clone());
Some(html)
} else {
None