﻿using System;

namespace PlayingBlue.Web.Caching
{
    /// <summary>
    /// Provides caching capabilities for <see cref="FaviconResolver"/>.
    /// </summary>
    public interface IFaviconCache
    {
        /// <summary>
        /// Add favicon to cache or update the existing one.
        /// </summary>
        /// <param name="pageUri">URI of the page that <paramref name="favicon"/> belongs to.</param>
        /// <param name="favicon"><see cref="Favicon"/> to add.</param>
        void AddOrUpdate(Uri pageUri, Favicon favicon);

        /// <summary>
        /// Remove all favicons from cache.
        /// </summary>
        void Clear();

        /// <summary>
        /// Remove favicon from cache for the specified page.
        /// </summary>
        /// <param name="pageUri">URI of the page that the favicon belongs to.</param>
        /// <returns><c>true</c> if the favicon was found and removed; otherwise, <c>false</c>.</returns>
        bool Remove(Uri pageUri);

        /// <summary>
        /// Try get favicon from cache for the specified URI.
        /// </summary>
        /// <param name="pageUri">Target page's URI.</param>
        /// <param name="favicon">
        /// When this method returns, contains the favicon for the page if found; 
        /// otherwise, <c>null</c>.
        /// </param>
        /// <returns><c>true</c> if favicon found in cache; otherwise, <c>false</c>.</returns>
        bool TryGet(Uri pageUri, out Favicon favicon);
    }
}
