Skip to content

Commit

Permalink
open-api: modify cache key (#705)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZzIsGod1019 authored Apr 9, 2024
1 parent 123a721 commit 9ba6d77
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions backend/supports/iam/src/basic/serv/iam_open_serv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,8 +483,16 @@ impl IamOpenServ {
Ok(IamOpenRuleResp {
cert_id,
spec_code,
start_time: time_range.split(',').collect_vec().first().map(|s| DateTime::parse_from_rfc3339(s).unwrap().with_timezone(&Utc)),
end_time: time_range.split(',').collect_vec().last().map(|s| DateTime::parse_from_rfc3339(s).unwrap().with_timezone(&Utc)),
start_time: if !time_range.is_empty() {
time_range.split(',').collect_vec().first().map(|s| DateTime::parse_from_rfc3339(s).unwrap().with_timezone(&Utc))
} else {
None
},
end_time: if !time_range.is_empty() {
time_range.split(',').collect_vec().last().map(|s| DateTime::parse_from_rfc3339(s).unwrap().with_timezone(&Utc))
} else {
None
},
api_call_frequency: IamIdentCacheServ::get_gateway_rule_info(&ak, OPENAPI_GATEWAY_PLUGIN_LIMIT, None, funs).await?.map(|s| s.parse::<u32>().unwrap_or_default()),
api_call_count: IamIdentCacheServ::get_gateway_rule_info(&ak, OPENAPI_GATEWAY_PLUGIN_COUNT, None, funs).await?.map(|s| s.parse::<u32>().unwrap_or_default()),
api_call_cumulative_count: IamIdentCacheServ::get_gateway_cumulative_count(&ak, None, funs).await?.map(|s| s.parse::<u32>().unwrap_or_default()),
Expand Down
2 changes: 1 addition & 1 deletion backend/supports/iam/src/iam_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ impl Default for IamConfig {
strict_security_mode: false,
crypto_conf: CryptoConf::default(),
cache_key_gateway_rule_info_: "sg:plugin:".to_string(),
gateway_openapi_path: "op-api".to_string(),
gateway_openapi_path: "/op-api".to_string(),
}
}
}
Expand Down

0 comments on commit 9ba6d77

Please sign in to comment.