@@ -102,27 +102,25 @@ impl EmailQuery {
102102
103103 let cached: Option < String > = conn. get ( & cache_key) . ok ( ) ;
104104
105- if let Some ( cached_str) = cached {
106- if let Ok ( cached_response) =
105+ if let Some ( cached_str) = cached
106+ && let Ok ( cached_response) =
107107 serde_json:: from_str :: < CachedValidationResponse > ( & cached_str)
108- {
109- return Some ( cached_response. into ( ) ) ;
110- }
108+ {
109+ return Some ( cached_response. into ( ) ) ;
111110 }
112111 }
113112 None
114113 }
115114
116115 async fn cache_result ( & self , email : & str , result : & EmailValidationResponse ) {
117- if let Some ( client) = & self . redis_client {
118- if let Ok ( mut conn) = client. get_connection ( ) {
119- let cache_key = format ! ( "email:validation:{}" , email) ;
120- let cached_response: CachedValidationResponse = ( * result) . clone ( ) . into ( ) ;
116+ if let Some ( client) = & self . redis_client
117+ && let Ok ( mut conn) = client. get_connection ( ) {
118+ let cache_key = format ! ( "email:validation:{}" , email) ;
119+ let cached_response: CachedValidationResponse = ( * result) . clone ( ) . into ( ) ;
121120
122- if let Ok ( json) = serde_json:: to_string ( & cached_response) {
123- let _: Result < ( ) , RedisError > =
124- conn. set_ex ( & cache_key, json, self . cache_ttl as usize ) ;
125- }
121+ if let Ok ( json) = serde_json:: to_string ( & cached_response) {
122+ let _: Result < ( ) , RedisError > =
123+ conn. set_ex ( & cache_key, json, self . cache_ttl as usize ) ;
126124 }
127125 }
128126 }
0 commit comments