Advertisement
FlyFar

redis.rs

Jul 24th, 2023
1,222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.46 KB | Cybersecurity | 0 0
  1. use redis::{Client, Commands, Connection, ToRedisArgs};
  2. use redis::RedisResult;
  3.  
  4. fn client() -> RedisResult<Connection> {
  5.     let redis = Client::open(crate::REDIS_KEY)?;
  6.     redis.get_connection()
  7. }
  8.  
  9. pub fn send(val: &String) -> RedisResult<bool> {
  10.     let mut client = client()?;
  11.     client.rpush(&crate::ram::CONST.who, val)
  12. }
  13.  
  14. pub fn exists<T : ToRedisArgs>(val : T)  -> RedisResult<bool> {
  15.     let mut client = client()?;
  16.     client.exists(val)
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement