Add project files.

This commit is contained in:
2025-08-26 09:20:13 -04:00
parent 6c6a149821
commit d2201d6f9b
118 changed files with 1924 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
using JSMR.Application.Common.Caching;
using JSMR.Application.Common.Search;
using JSMR.Application.Creators.Queries.Search.Contracts;
using JSMR.Application.Creators.Queries.Search.Ports;
namespace JSMR.Application.Creators.Queries.Search;
public sealed class SearchCreatorsHandler(ICreatorSearchProvider searchProvider, ICache cache)
{
public async Task<SearchCreatorsResponse> HandleAsync(SearchCreatorsRequest request, CancellationToken cancellationToken)
{
SearchOptions<CreatorSearchCriteria, CreatorSortField> searchOptions = request.Options;
string cacheKey = $"creator:{searchOptions.GetHashCode()}";
CreatorSearchResults? cachedResults = await cache.GetAsync<CreatorSearchResults>(cacheKey, cancellationToken);
if (cachedResults != null)
return new SearchCreatorsResponse(cachedResults);
SearchResult<CreatorSearchItem> results = await searchProvider.SearchAsync(searchOptions, cancellationToken);
CacheEntryOptions cacheEntryOptions = new()
{
SlidingExpiration = TimeSpan.FromMinutes(10)
};
await cache.SetAsync(cacheKey, results, cacheEntryOptions, cancellationToken);
return new SearchCreatorsResponse(results);
}
}