//! Thumbnail caching with LRU eviction
//!
//! This module handles caching image thumbnails from Jellyfin servers with:
//! - Lazy caching (cache as viewed)
//! - LRU (Least Recently Used) eviction when storage limit reached
//! - Configurable storage limits
//! - SQLite-backed cache metadata

pub mod cache;
pub mod worker;

pub use cache::{CacheConfig, ThumbnailCache};
pub use worker::ThumbnailWorker;

/// Statistics about the thumbnail cache
#[derive(specta::Type, Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ThumbnailCacheStats {
    pub total_size_bytes: u64,
    pub item_count: i64,
    pub limit_bytes: u64,
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_stats_serialization() {
        let stats = ThumbnailCacheStats {
            total_size_bytes: 1024,
            item_count: 10,
            limit_bytes: 1073741824,
        };

        let json = serde_json::to_string(&stats).unwrap();
        assert!(json.contains("\"totalSizeBytes\":1024"));
        assert!(json.contains("\"itemCount\":10"));
        assert!(json.contains("\"limitBytes\":1073741824"));
    }
}
