Skip to content

Commit

Permalink
dummy cache backend enabled
Browse files Browse the repository at this point in the history
to exclude possible LRU.get failure
  • Loading branch information
fevral13 committed Feb 29, 2024
1 parent fd5eb15 commit 685732b
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "evalrs"
version = "0.1.6"
version = "0.1.7-dummy_cache"
authors = ["Serhii Zavadskyi <fevral13@gmail.com>"]
edition = "2021"

Expand Down
12 changes: 8 additions & 4 deletions src/app_state.rs
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),
}
}
}
17 changes: 17 additions & 0 deletions src/cache_backend/dummy_backend.rs
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
}
}
1 change: 1 addition & 0 deletions src/cache_backend/mod.rs
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;

Expand Down

0 comments on commit 685732b

Please sign in to comment.