disable cache from redis
- reason from value not updated Signed-off-by: Pakin <pakin.t@forth.co.th>
This commit is contained in:
parent
b70a35135c
commit
a69ef7b927
1 changed files with 0 additions and 30 deletions
30
src/app.rs
30
src/app.rs
|
|
@ -125,24 +125,6 @@ async fn checkout_handler(
|
||||||
// );
|
// );
|
||||||
|
|
||||||
// quick response from redis
|
// quick response from redis
|
||||||
if let Ok(conn) = state.redis.dedicated_connection().await {
|
|
||||||
println!("conneciton ok");
|
|
||||||
if let Ok(raw) = fetch_content_from_redis_byte(conn, &fpath).await
|
|
||||||
&& !raw.is_empty()
|
|
||||||
{
|
|
||||||
// detect content type
|
|
||||||
let content_type = detect_content_type(&fpath);
|
|
||||||
|
|
||||||
println!("content-len: {}", raw.len());
|
|
||||||
|
|
||||||
return Response::builder()
|
|
||||||
.header(header::CONTENT_TYPE, content_type)
|
|
||||||
.body(Body::from(raw))
|
|
||||||
.unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
println!("failed to get from redis, continue ...");
|
|
||||||
|
|
||||||
let repo = state.repo.clone();
|
let repo = state.repo.clone();
|
||||||
|
|
||||||
|
|
@ -186,18 +168,6 @@ async fn checkout_handler(
|
||||||
let key_clone = fpath.clone();
|
let key_clone = fpath.clone();
|
||||||
let data_clone = o.clone();
|
let data_clone = o.clone();
|
||||||
|
|
||||||
tokio::spawn(async move {
|
|
||||||
if let Ok(mut conn) = state_clone.redis.dedicated_connection().await {
|
|
||||||
let _: Result<(), _> = redis::cmd("SET")
|
|
||||||
.arg(&key_clone)
|
|
||||||
.arg(&data_clone)
|
|
||||||
.arg("EX")
|
|
||||||
.arg(3600)
|
|
||||||
.query_async(&mut conn)
|
|
||||||
.await;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
let content_type = detect_content_type(&fpath);
|
let content_type = detect_content_type(&fpath);
|
||||||
Response::builder()
|
Response::builder()
|
||||||
.header(header::CONTENT_TYPE, content_type)
|
.header(header::CONTENT_TYPE, content_type)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue