Hi, I can’t seem to get CacheResponse attribute working on an async method. Simplified code below:
v6.8
[CacheResponse(Duration = 60000)]
public async Task<List<Dto>> Get(GetItems request)
{
return await data.GetItems(request);
}
The Redis [Prefix]:res:{key} items are being populated (and are refreshed on every call), but these are never retrieved, the execution always goes into the method.
Am I missing something?
mythz
March 21, 2024, 7:52am
2
Are you getting different behavior based on whether this was a sync vs async method?
The behaviour is the same on sync and async.
One thing to consider is we’re using .WithPrefix("xxx")
on the
GetCacheClient
& GetCacheClientAsync
.
The entries are appearing with the prefix accurately prepended, but perhaps the HandleValidCache
isn’t including the prefix?
mythz
March 21, 2024, 4:51pm
4
Possibly, is the behavior different without a prefix?
Yes, it works correctly without a prefix, but the addition of a prefix always calls the factory method.
mythz
March 26, 2024, 5:20pm
6
Can you verify if using a local cache works?
[CacheResponse(Duration = 60000, LocalCache = true)]
Can you also check your Redis cache and let me know which keys are stored without a prefix?