Replies: 1 comment 1 reply
-
默认情况,设置缓存的时候会加一个随机过期时间,打散过期时间,避免集中过期,如果不需要这个,可以设置 maxrdsecond 为 0。 option.UseInMemory(x =>
{
x.MaxRdSecond = 0;
}, "default"); |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
我在测试Interceptors的时候发现两个问题,还请百忙之中帮忙看看是否是我那里用的不对,多谢。
问题1:easycachingable的expiration=5时实际要更久才能刷新
复现步骤:
用sample的代码 https://github.com/dotnetcore/EasyCaching/tree/dev/sample/EasyCaching.Demo.Interceptors
尝试用castle方式,修改代码如下图

启动项目
预期行为:https://localhost:54738/api/values/castle的返回值应该5秒一变
实际:可能要几分钟才变,见下图
问题2:builder.ConfigureCastleInterceptor()放在最后会忽略之前的builder.RegisterType,放在前面则cache不生效。同时builder.ConfigureCastleInterceptor()会忽略service.AddScoped等方法
环境:.net6, .netcore 3.1
复现步骤
Program.cs
Controller:

尝试访问该接口,发现被注入的service不是指定的AnotherService而是WeatherService


如果交换ConfigureCastleInterceptor和RegisterType的顺序,被注入的service正确但并未被castle正确拦截
.netcore 3.1无法人为指定顺序,但指定的依赖绑定失效。
update:
似乎找到了一种符合预期的写法,但不太确定是否是best practice
Beta Was this translation helpful? Give feedback.
All reactions