QuickDID is a high-performance AT Protocol identity resolution service written in Rust. It provides handle-to-DID resolution with Redis-backed caching and queue processing.
1//! Redis cache utilities for QuickDID
2
3use deadpool_redis::{Config, Pool, Runtime};
4use thiserror::Error;
5
6/// Cache-specific errors
7#[derive(Debug, Error)]
8pub enum CacheError {
9 /// Redis pool creation failed
10 #[error("error-quickdid-cache-1 Redis pool creation failed: {0}")]
11 RedisPoolCreationFailed(String),
12}
13
14/// Create a Redis connection pool from a Redis URL.
15///
16/// # Arguments
17///
18/// * `redis_url` - Redis connection URL (e.g., "redis://localhost:6379/0")
19///
20/// # Errors
21///
22/// Returns an error if:
23/// - The Redis URL is invalid
24/// - Pool creation fails
25pub fn create_redis_pool(redis_url: &str) -> Result<Pool, CacheError> {
26 let config = Config::from_url(redis_url);
27 let pool = config
28 .create_pool(Some(Runtime::Tokio1))
29 .map_err(|e| CacheError::RedisPoolCreationFailed(e.to_string()))?;
30 Ok(pool)
31}