什么时候适合使用CacheItemRemovedCallback? [英] When is it appropriate to use CacheItemRemovedCallback?

查看:560
本文介绍了什么时候适合使用CacheItemRemovedCallback?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个每天更新一次大型数据集。我缓存上的数据昂贵查询的结果,但我想每天更新缓存。我正在考虑使用CacheItemRemovedCallback重新加载我的每天的时间间隔缓存,但我有如下几个问题:

I have a large data set that is updated once a day. I am caching the results of an expensive query on that data but I want to update that cache each day. I am considering using CacheItemRemovedCallback to reload my cache on a daily interval, but I had the following concerns:


  1. 是不是有可能是CacheItemRemovedCallback可以被称为我的有效期届满前(在运行内存的情况下)?这意味着重装立刻似乎不是一个好主意。

  2. 是否CacheItemRemovedCallback得到之前或实际上项被删除后,叫什么名字?如果是后,不会将该理论上离开的一段时间,其中所述高速缓存将是不可用的?

有关这些问题,如果使用CacheItemRemovedCallback重新加载缓存是一个坏主意,那么当是它有用吗?

Are these concerns relevant and if using CacheItemRemovedCallback to reload your cache is a bad idea, then when is it useful?

推荐答案

从大家的反应和进一步的阅读中,我得出的结论如下:

From everyone's responses and from further reading I have come to the following conclusion:

我的担忧是有效的。使用CacheItemRemovedCallback刷新缓存的项目是不是一个好主意。这个回调的唯一实际使用似乎是登录时缓存被删除相关信息。

My concerns are valid. Using CacheItemRemovedCallback to refresh cached items is not a good idea. The only practical use for this callback seems to be logging information about when your cache is removed.

似乎CacheItemUpdateCallback是固定的间隔刷新缓存的更合适的方式。

It seems that CacheItemUpdateCallback is the more appropriate way of refreshing your cache on a regular interval.

最后,我决定不使用这两种调用。相反,我会写一个服务动作,所以当它需要刷新其数据的数据库导入作业可以通知我的申请。这样就避免了完全使用定时刷新。

Ultimately, I have decided not to use either of these calls. Instead I will write a service action so the database import job can notify my application when it needs to refresh its data. This avoids using a timed refresh altogether.

这篇关于什么时候适合使用CacheItemRemovedCallback?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆