remove logging
This commit is contained in:
1 parent
3a690877d1
commit
3d41dd95c9
2 files changed
+12
-5
No files matched your search
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
use dioxus_router::prelude::*;
|
use dioxus_router::prelude::*;
|
||||||
|
|
||||||
use dioxus_router::ssr::{DefaultRenderer, IncrementalRendererConfig};
|
use dioxus_router::ssr::{DefaultRenderer, IncrementalRendererConfig};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
@@ -21,7 +22,6 @@ fn main() {
|
|||||||
.to_string(),
|
.to_string(),
|
||||||
})
|
})
|
||||||
.static_dir("./static")
|
.static_dir("./static")
|
||||||
.memory_cache_limit(5)
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
renderer.pre_cache_static::<Route>();
|
renderer.pre_cache_static::<Route>();
|
||||||
|
|||||||
@@ -132,8 +132,16 @@ impl<R: RenderHTML> IncrementalRenderer<R> {
|
|||||||
let file = std::fs::File::create(dbg!(file_path)).unwrap();
|
let file = std::fs::File::create(dbg!(file_path)).unwrap();
|
||||||
let mut file = std::io::BufWriter::new(file);
|
let mut file = std::io::BufWriter::new(file);
|
||||||
file.write_all(html.as_bytes()).unwrap();
|
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() {
|
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()
|
.as_mut()
|
||||||
.and_then(|cache| cache.get(&route).cloned())
|
.and_then(|cache| cache.get(&route).cloned())
|
||||||
{
|
{
|
||||||
println!("memory cache hit");
|
|
||||||
Some(cache_hit)
|
Some(cache_hit)
|
||||||
} else {
|
} else {
|
||||||
let file_path = self.route_as_path(&route);
|
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 file = std::io::BufReader::new(file);
|
||||||
let mut html = String::new();
|
let mut html = String::new();
|
||||||
file.read_to_string(&mut html).ok()?;
|
file.read_to_string(&mut html).ok()?;
|
||||||
println!("file cache hit");
|
self.add_to_memory_cache(route, html.clone());
|
||||||
Some(html)
|
Some(html)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|||||||
Reference in new issue
Block a user