从 HangFire 的缓存中添加和获取数据
Add ang get data from cache from HangFire
我正在尝试使用 Hangfire 更新缓存中的一些列表 (HttpContext.Current.Cache
)。我得到一个 NullReferenceException
因为 HttpContext
在 Hangfire 调用它时是 null
。
有没有办法为此使用 Hangfire,或者我应该寻找另一个框架?
你不能执行 changing context like HttpContext
inside Hangfire because Hangfire can run jobs in different server and machine. If you want to access changing context like HttpContext
probably you need to have at least share storage to do that and dkempner 有针对此方案的建议,但直到现在才发生。
我正在尝试使用 Hangfire 更新缓存中的一些列表 (HttpContext.Current.Cache
)。我得到一个 NullReferenceException
因为 HttpContext
在 Hangfire 调用它时是 null
。
有没有办法为此使用 Hangfire,或者我应该寻找另一个框架?
你不能执行 changing context like HttpContext
inside Hangfire because Hangfire can run jobs in different server and machine. If you want to access changing context like HttpContext
probably you need to have at least share storage to do that and dkempner 有针对此方案的建议,但直到现在才发生。