feat: add redis caching #11

Merged
radical merged 5 commits from wip/redis-caching into main 2025-05-07 21:04:40 +00:00
2 changed files with 2 additions and 3 deletions
Showing only changes of commit 3e65cffe39 - Show all commits

View file

@ -37,7 +37,7 @@ pub async fn res(
let cache_result = data.get_cache_key(uuid.to_string()).await;
if let Ok(cache_hit) = cache_result {
return Ok(HttpResponse::Ok().json(cache_hit))
return Ok(HttpResponse::Ok().content_type("application/json").body(cache_hit))
}
let row = sqlx::query_as(&format!(

View file

@ -3,7 +3,6 @@ use getrandom::fill;
use hex::encode;
use redis::RedisError;
use serde::Serialize;
use serde_json::json;
use crate::Data;
@ -57,7 +56,7 @@ impl Data {
let key_encoded = encode(key);
let value_json = json!(value).as_str().unwrap().to_string();
let value_json = serde_json::to_string(&value).unwrap();
redis::cmd("SET",).arg(&[key_encoded.clone(), value_json]).exec_async(&mut conn).await?;