The smokesignal.events web application
1use anyhow::Result;
2use deadpool_redis::{Config, Pool, Runtime};
3
4use crate::storage::errors::CacheError;
5
6pub fn create_cache_pool(redis_url: &str) -> Result<Pool> {
7 let cfg = Config::from_url(redis_url);
8 cfg.create_pool(Some(Runtime::Tokio1))
9 .map_err(|err| CacheError::FailedToCreatePool(err).into())
10}
11
12// Mock implementation for testing
13#[cfg(test)]
14pub struct MockCachePool {}
15
16#[cfg(test)]
17impl std::fmt::Debug for MockCachePool {
18 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
19 f.debug_struct("MockCachePool").finish()
20 }
21}
22
23#[cfg(test)]
24impl Clone for MockCachePool {
25 fn clone(&self) -> Self {
26 Self {}
27 }
28}