pub struct ApiCache { /* private fields */ }Expand description
Cache for GitHub API responses.
Stores JSON responses in SQLite with configurable TTL. Thread-safe via internal connection management.
Implementations§
Source§impl ApiCache
impl ApiCache
Sourcepub fn open(path: impl AsRef<Path>) -> Result<Self>
pub fn open(path: impl AsRef<Path>) -> Result<Self>
Open or create cache at the given path.
If the database doesn’t exist, it will be created with the schema.
Sourcepub fn open_in_memory() -> Result<Self>
pub fn open_in_memory() -> Result<Self>
Create an in-memory cache (for testing).
Sourcepub fn get<T: DeserializeOwned>(&self, key: &str) -> Result<Option<T>>
pub fn get<T: DeserializeOwned>(&self, key: &str) -> Result<Option<T>>
Get a cached value if it exists and hasn’t expired.
Sourcepub fn set<T: Serialize>(&self, key: &str, value: &T) -> Result<()>
pub fn set<T: Serialize>(&self, key: &str, value: &T) -> Result<()>
Store a value in the cache.
Sourcepub fn set_with_ttl<T: Serialize>(
&self,
key: &str,
value: &T,
ttl: Duration,
) -> Result<()>
pub fn set_with_ttl<T: Serialize>( &self, key: &str, value: &T, ttl: Duration, ) -> Result<()>
Store a value with a custom TTL.
Sourcepub fn cleanup_expired(&self) -> Result<usize>
pub fn cleanup_expired(&self) -> Result<usize>
Remove expired entries from the cache.
Sourcepub fn stats(&self) -> Result<CacheStats>
pub fn stats(&self) -> Result<CacheStats>
Get cache statistics.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ApiCache
impl !RefUnwindSafe for ApiCache
impl Send for ApiCache
impl !Sync for ApiCache
impl Unpin for ApiCache
impl UnsafeUnpin for ApiCache
impl !UnwindSafe for ApiCache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more