46 lines
1.7 KiB
C#
Executable File
46 lines
1.7 KiB
C#
Executable File
using System.Threading.Tasks;
|
|
|
|
namespace ZB.MOM.WW.CBDDC.Core.Cache
|
|
{
|
|
/// <summary>
|
|
/// Defines operations for caching documents by collection and key.
|
|
/// </summary>
|
|
public interface IDocumentCache
|
|
{
|
|
/// <summary>
|
|
/// Clears all cached documents.
|
|
/// </summary>
|
|
void Clear();
|
|
|
|
/// <summary>
|
|
/// Gets a cached document by collection and key.
|
|
/// </summary>
|
|
/// <param name="collection">The collection name.</param>
|
|
/// <param name="key">The document key.</param>
|
|
/// <returns>The cached document, or <see langword="null"/> if not found.</returns>
|
|
Task<Document?> Get(string collection, string key);
|
|
|
|
/// <summary>
|
|
/// Gets cache hit/miss statistics.
|
|
/// </summary>
|
|
/// <returns>A tuple containing hits, misses, current size, and hit rate.</returns>
|
|
(long Hits, long Misses, int Size, double HitRate) GetStatistics();
|
|
|
|
/// <summary>
|
|
/// Removes a cached document by collection and key.
|
|
/// </summary>
|
|
/// <param name="collection">The collection name.</param>
|
|
/// <param name="key">The document key.</param>
|
|
void Remove(string collection, string key);
|
|
|
|
/// <summary>
|
|
/// Adds or updates a cached document.
|
|
/// </summary>
|
|
/// <param name="collection">The collection name.</param>
|
|
/// <param name="key">The document key.</param>
|
|
/// <param name="document">The document to cache.</param>
|
|
/// <returns>A task that represents the asynchronous operation.</returns>
|
|
Task Set(string collection, string key, Document document);
|
|
}
|
|
}
|