Skip to main content

#
jellytau_lib/thumbnail/
mod.rs

    1//! Thumbnail caching with LRU eviction
    2//!
    3//! This module handles caching image thumbnails from Jellyfin servers with:
    4//! - Lazy caching (cache as viewed)
    5//! - LRU (Least Recently Used) eviction when storage limit reached
    6//! - Configurable storage limits
    7//! - SQLite-backed cache metadata
    8
    9pub mod cache;
    10pub mod worker;
    11
    12pub use cache::{CacheConfig, ThumbnailCache};
    13pub use worker::ThumbnailWorker;
    14
    15/// Statistics about the thumbnail cache
    16#[derive(specta::Type, Debug, Clone, serde::Serialize, serde::Deserialize)]
    17#[serde(rename_all = "camelCase")]
    18pub struct ThumbnailCacheStats {
    19    pub total_size_bytes: u64,
    20    pub item_count: i64,
    21    pub limit_bytes: u64,
    22}
    23
    24#[cfg(test)]
    25mod tests {
    26    use super::*;
    27
    28    #[test]
    29    fn test_stats_serialization() {
    30        let stats = ThumbnailCacheStats {
    31            total_size_bytes: 1024,
    32            item_count: 10,
    33            limit_bytes: 1073741824,
    34        };
    35
    36        let json = serde_json::to_string(&stats).unwrap();
    37        assert!(json.contains("\"totalSizeBytes\":1024"));
    38        assert!(json.contains("\"itemCount\":10"));
    39        assert!(json.contains("\"limitBytes\":1073741824"));
    40    }
    41}