Closed attiqeurrehman closed 5 years ago
It won't work with ProjectTo
of auto-mapper. the Cacheable
method needs to evaluate the expression tree to find its dependencies and also its hash and the result of the query (to cache it) and it's not possible with the ProjectTo
method.
But I have removed it from the get single request handler. I am using ahtomapper after I have the result and it caches first item but not the other items.
-A
On 01-Aug-2018, at 4:53 PM, Vahid Nasiri notifications@github.com wrote:
It won't work with ProjectTo of auto-mapper. the Cacheable method needs to evaluate the expression tree to find dependencies and also its hash and it's not possible with the ProjectTo method.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
Following is the code for RestSingleGetHandler
protected override async Task<TSingleGetModel> OnHandleAsync(
RestSingleGetRequest<TEntity, TSingleGetModel> message,
CancellationToken cancellationToken)
{
var ret = await UnitOfWork.GetRepository<TEntity>()
.GetAll()
.Cacheable()
.FirstOrDefaultAsync(e => e.Id == message.Id, cancellationToken);
if (ret == null) throw new EntityNotFoundException(typeof(TEntity), message.Id);
return Mapper.Map<TSingleGetModel>(ret);
}
It works for the first time and create cache in Redis but for next requests it gives weird results.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related problems.
Summary of the issue
I am unable to get the correct response from the Redis Cache, it's not creating the collection of keys or creating other keys once it already has the keys for any other get request.
Environment
Example code/Steps to reproduce:
Opiniated.zip
Output:
I am not getting the correct response.