You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using midiatR, we could easily archive something like this to simplify query cache.
publicclassCacheBehavior<TQuery,TResponse>:IPipelineBehavior<TQuery,TResponse>whereTQuery:ICachableQuerywhereTResponse:ICachableQueryResponse{publicasyncTask<TResponse>Handle(TQueryrequest,CancellationTokencancellationToken,RequestHandlerDelegate<TResponse>next){if(request.AllowCache ==false){returnawait next();}varcacheResult=await _cacheService.Get<TResponse>(request.CacheKey);if(cacheResult is not null){returncacheResult;}varfreshResult=await next();await _cacheService.Add<TResponse>(request.CacheKey, request.CacheTime);returnfreshResult;}}
The text was updated successfully, but these errors were encountered:
Using midiatR, we could easily archive something like this to simplify query cache.
The text was updated successfully, but these errors were encountered: