using BomLocalService.Models; namespace BomLocalService.Services.Interfaces; /// /// Service interface for managing cached radar screenshot files and metadata. /// Handles file system operations for storing and retrieving cached BOM radar screenshots. /// public interface ICacheService { /// /// Gets the cached screenshot file path and associated metadata for a location. /// Searches for PNG files matching the location pattern and loads the corresponding metadata JSON file. /// /// The suburb name (e.g., "Pomona", "Brisbane") /// The Australian state abbreviation (e.g., "QLD", "NSW", "VIC") /// Cancellation token to cancel the operation /// Tuple containing the screenshot file path and metadata, or (null, null) if not found Task<(string? screenshotPath, LastUpdatedInfo? metadata)> GetCachedScreenshotWithMetadataAsync( string suburb, string state, CancellationToken cancellationToken = default); /// /// Saves metadata JSON file alongside a screenshot file. /// Creates a JSON file with the same base name as the screenshot but with .json extension. /// /// Full path to the screenshot PNG file /// Metadata to save (observation time, forecast time, weather station, distance) /// Cancellation token to cancel the operation Task SaveMetadataAsync(string screenshotPath, LastUpdatedInfo metadata, CancellationToken cancellationToken = default); /// /// Checks if cached metadata is still valid (not expired). /// Cache is valid if observation time + expiration buffer (typically 15.5 minutes) is still in the future. /// BOM updates observations every 15 minutes, so the buffer accounts for timing variations. /// /// The metadata to validate, or null /// True if metadata exists and cache is still valid, false otherwise bool IsCacheValid(LastUpdatedInfo? metadata); /// /// Gets the file system path to the most recent cached screenshot for a location. /// Returns files ordered by creation time, most recent first. /// /// The suburb name (e.g., "Pomona", "Brisbane") /// The Australian state abbreviation (e.g., "QLD", "NSW", "VIC") /// Cancellation token to cancel the operation /// File system path to the cached screenshot, or empty string if not found Task GetCachedScreenshotPathAsync(string suburb, string state, CancellationToken cancellationToken = default); /// /// Deletes all cached files (PNG screenshots and JSON metadata) for a location. /// /// The suburb name (e.g., "Pomona", "Brisbane") /// The Australian state abbreviation (e.g., "QLD", "NSW", "VIC") /// Cancellation token to cancel the operation /// True if any files were deleted, false if no cached files existed Task DeleteCachedLocationAsync(string suburb, string state, CancellationToken cancellationToken = default); /// /// Gets the cache directory path where screenshots and metadata are stored. /// /// The full path to the cache directory string GetCacheDirectory(); }