-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
to exclude possible LRU.get failure
- Loading branch information
Showing
5 changed files
with
28 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,22 @@ | ||
use std::sync::Mutex; | ||
|
||
use crate::cache_backend::local_memory_backend::LocalMemoryCacheBackend; | ||
use crate::cache_backend::dummy_backend::DummyCacheBackend; | ||
use crate::settings::Settings; | ||
|
||
pub struct AppState { | ||
pub tera: tera::Tera, | ||
pub settings: Settings, | ||
pub cache: Mutex<LocalMemoryCacheBackend>, | ||
pub cache: Mutex<DummyCacheBackend>, | ||
} | ||
|
||
impl AppState { | ||
pub fn new(settings: Settings) -> Self { | ||
let tera = crate::templates::init_templates(); | ||
let cache = LocalMemoryCacheBackend::new(100); | ||
AppState{tera, settings, cache: Mutex::new(cache)} | ||
let cache = DummyCacheBackend::new(); | ||
AppState { | ||
tera, | ||
settings, | ||
cache: Mutex::new(cache), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use crate::cache_backend::CacheBackend; | ||
|
||
pub struct DummyCacheBackend {} | ||
|
||
impl DummyCacheBackend { | ||
pub fn new() -> Self { | ||
DummyCacheBackend {} | ||
} | ||
} | ||
|
||
impl CacheBackend for DummyCacheBackend { | ||
fn set(self: &mut DummyCacheBackend, id: &str, value: &str) {} | ||
|
||
fn get(self: &mut DummyCacheBackend, id: &str) -> Option<&String> { | ||
None | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod dummy_backend; | ||
pub mod local_memory_backend; | ||
mod test_local_memory_backend; | ||
|
||
|