27 lines
673 B
Rust
27 lines
673 B
Rust
use anyhow::Result;
|
|
use lazy_static::lazy_static;
|
|
use r2d2_redis::{r2d2, RedisConnectionManager};
|
|
|
|
use crate::config;
|
|
|
|
pub type CachePool = r2d2::Pool<RedisConnectionManager>;
|
|
pub type ConnectionPool = r2d2::PooledConnection<RedisConnectionManager>;
|
|
|
|
pub fn establish_connection() -> Result<RedisConnectionManager> {
|
|
Ok(RedisConnectionManager::new(
|
|
config::CONFIG.redis_url.as_str(),
|
|
)?)
|
|
}
|
|
|
|
pub fn pool() -> Result<CachePool> {
|
|
Ok(r2d2::Pool::builder().build(establish_connection()?)?)
|
|
}
|
|
|
|
lazy_static! {
|
|
pub static ref POOL: CachePool = pool().unwrap();
|
|
}
|
|
|
|
pub mod keys {
|
|
// pub const LAST_SUBSTITUTION_QUERY_ID: &str = "last_subst_query_id";
|
|
}
|