Created
February 27, 2024 07:20
-
-
Save simanacci/5f6150c5023befddfbe03377832e7143 to your computer and use it in GitHub Desktop.
FT.CREATE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub async fn message<T>( | |
redis: &redis::Client, | |
sms: T, | |
gadget: Option<Uuid>, | |
uuid: Uuid, | |
) -> Result<Message, CustomError> | |
where | |
T: AsRef<str> + ToString, | |
{ | |
if !helper::index_exists(redis, common::index::MESSAGES).await { | |
let data = IndexData::messages(); | |
IndexData::create_index(redis, data).await.unwrap(); | |
} | |
let message = Message { | |
uuid, | |
gadget, | |
sms: sms.to_string(), | |
added: Utc::now(), | |
}; | |
let items = message_items(&message); | |
Cache::hset_multiple(redis, key::message(message.uuid.to_string()), &items) | |
.await | |
.unwrap(); | |
Ok(message) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment