use std::time::Duration;
use fred::error::Error as FredError;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("encode cache value for key [{key}]: {source}")]
Encode {
key: String,
source: serde_json::Error,
},
#[error("decode cache value for key [{key}]: {source}")]
Decode {
key: String,
source: serde_json::Error,
},
#[error("cache value for key [{0}] cannot be null")]
NullValue(String),
#[error("cache value for key [{key}] is not a signed integer")]
NotInteger {
key: String,
},
#[error("integer cache mutation overflowed for key [{0}]")]
IntegerOverflow(String),
#[error("redis cache operation failed: {0}")]
Redis(#[from] FredError),
#[error("timed out after {0:?} while acquiring cache lock")]
LockTimeout(Duration),
}
#[derive(Debug, thiserror::Error)]
pub enum RememberError<E> {
#[error(transparent)]
Cache(#[from] Error),
#[error("cache value resolver failed: {0}")]
Resolve(E),
}