Closed ioer2008 closed 3 years ago
Hi @ioer2008 , Could you please provide some more context to the issue? The aspect code and target code (where you apply aspect) will help a lot!
Sorry, the code is uploaded to https://github.com/ioer2008/OrleansDemo.
in /Grains/RedisCacheAttribute.cs,the result value can't set to redis.
I made a new version of Aspects.Cache so it should should work with your case:
dotnet add package Aspects.Cache --version 2.0.0
public class RedisCacheAttribute : DistributedCacheBaseAttribute
{
private static readonly RedisCache _cache = new RedisCache(new OptionsWrapper<RedisCacheOptions>(new RedisCacheOptions
{
Configuration = "localhost:6379",
InstanceName = "Example"
}));
public RedisCacheAttribute(uint seconds, bool perInstanceCache = false)
{
Policy = new DistributedCacheEntryOptions { AbsoluteExpiration = DateTimeOffset.UtcNow.AddSeconds(seconds) };
PerInstanceCache = perInstanceCache;
}
public override IDistributedCache Cache => _cache;
public override DistributedCacheEntryOptions Policy { get; }
}
Thank you very much for your modification, but I added the above code to the file and still reported an error. Maybe it doesn't support Orleans.
Well I guess it doesn't directly support async methods, so if you want to cache one of them - additional development is required, you can refer here on how to do it https://github.com/pamidur/aspect-injector/tree/master/samples/src/Universal - this is brand new universal wrapper - much more robust and has more features.
Anyway we have not tested it against Orleans, though I don't see any critical problems with it.
var result = await ((Task)target(args)).ConfigureAwait(false);
If you execute this sentence, you will report an error.
The official UniversalWrapper sample run exits directly, changes it to .net 5, and throws an exception "System.Exception".
Can you give an official example of using redis and task