Skip to content

Commit

Permalink
refactor cache
Browse files Browse the repository at this point in the history
  • Loading branch information
akshay111meher committed Nov 21, 2024
1 parent a6ae2d5 commit 10fff56
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
6 changes: 5 additions & 1 deletion matching_engine/src/routes/ui_routes/dashboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ pub async fn get_dashboard(
_local_native_store: Data<Arc<RwLock<NativeStakingStore>>>,
_local_symbiotic_store: Data<Arc<RwLock<SymbioticStakeStore>>>,
) -> actix_web::Result<HttpResponse> {
try_read_and_get_if_valid!(DASHBOARD_RESPONSE, dashboard_cache, Duration::from_millis(100));
try_read_and_get_if_valid!(
DASHBOARD_RESPONSE,
dashboard_cache,
Duration::from_millis(100)
);
drop(dashboard_cache);

try_read_or_lock!(_local_ask_store, local_ask_store);
Expand Down
6 changes: 5 additions & 1 deletion matching_engine/src/routes/ui_routes/generators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ pub async fn get_generators_all(
_local_native_store: Data<Arc<RwLock<NativeStakingStore>>>,
_local_symbiotic_store: Data<Arc<RwLock<SymbioticStakeStore>>>,
) -> actix_web::Result<HttpResponse> {
try_read_and_get_if_valid!(GENERATOR_RESPONSE, generator_cache, Duration::from_millis(100));
try_read_and_get_if_valid!(
GENERATOR_RESPONSE,
generator_cache,
Duration::from_millis(100)
);
drop(generator_cache);

try_read_or_lock!(_local_generator_store, local_generator_store);
Expand Down
2 changes: 1 addition & 1 deletion matching_engine/src/routes/ui_routes/single_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ pub async fn single_generator(
};

let cached_response = match SINGLE_GENERATOR_RESPONSE.try_read() {
Ok(data) => data.get(&generator_query, Duration::from_secs(10)),
Ok(data) => data.get(&generator_query, Duration::from_millis(100)),
_ => {
return Ok(HttpResponse::Locked().json(WelcomeResponse {
status: "Resource Busy".into(),
Expand Down
2 changes: 1 addition & 1 deletion matching_engine/src/routes/ui_routes/single_market.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ pub async fn single_market(
};

let cached_response = match SINGLE_MARKET_RESPONSE.try_read() {
Ok(data) => data.get(&market_query, Duration::from_secs(10)),
Ok(data) => data.get(&market_query, Duration::from_millis(100)),
_ => {
return Ok(HttpResponse::Locked().json(WelcomeResponse {
status: "Resource Busy".into(),
Expand Down

0 comments on commit 10fff56

Please sign in to comment.