using Microsoft.Extensions.Caching.Memory;
namespace BankSampahApp.Services;
///
/// Interface untuk cache service yang mengelola caching operations
///
public interface ICacheService
{
///
/// Gets cached value or sets it using the provider function
///
/// Type of cached data
/// Cache key
/// Function to provide data if not in cache
/// Cache expiration time
/// Cache priority
/// Cached or fresh data
Task GetOrSetAsync(string key, Func> provider, TimeSpan expiration, CacheItemPriority priority = CacheItemPriority.Normal);
///
/// Gets cached value or sets it using sliding expiration
///
/// Type of cached data
/// Cache key
/// Function to provide data if not in cache
/// Sliding expiration time
/// Absolute expiration time
/// Cache priority
/// Cached or fresh data
Task GetOrSetWithSlidingAsync(string key, Func> provider, TimeSpan slidingExpiration, TimeSpan absoluteExpiration, CacheItemPriority priority = CacheItemPriority.Normal);
///
/// Gets value from cache
///
/// Type of cached data
/// Cache key
/// Cached value or default
T? Get(string key);
///
/// Sets value in cache
///
/// Type of data to cache
/// Cache key
/// Value to cache
/// Cache expiration time
/// Cache priority
void Set(string key, T value, TimeSpan expiration, CacheItemPriority priority = CacheItemPriority.Normal);
///
/// Removes value from cache
///
/// Cache key
void Remove(string key);
///
/// Removes multiple cache entries by pattern
///
/// Pattern to match cache keys
void RemoveByPattern(string pattern);
///
/// Checks if key exists in cache
///
/// Cache key
/// True if key exists
bool Exists(string key);
}