Python中的缓存密钥过期事件或回调
我试图找到一种方法,当python中的缓存项过期时,接收对用户函数的调用 此功能已存在于.NET中,如下所示:Python中的缓存密钥过期事件或回调,python,caching,Python,Caching,我试图找到一种方法,当python中的缓存项过期时,接收对用户函数的调用 此功能已存在于.NET中,如下所示: string test = "test1"; Cache.Insert("Key", test, dependancy, DateTime.Now.AddMinutes(DateTime.Now), System.Web.Caching.Cache.NoSlidingExpiration, CacheItemPriority.High,
string test = "test1";
Cache.Insert("Key",
test,
dependancy,
DateTime.Now.AddMinutes(DateTime.Now),
System.Web.Caching.Cache.NoSlidingExpiration,
CacheItemPriority.High,
new CacheItemRemovedCallback(CacheRemovedCallback));
public string CacheRemovedCallback(String key, object value, System.Web.Caching.CacheItemRemovedReason removedReason)
{
//Do something here
return = "Cache Expired for : " + key;
}
非常感谢您的任何建议。您使用的是特定的缓存库还是即将选择的缓存库?@Leon我目前没有任何选择。任何东西都是健壮的、可用于生产的,并且具有基本的数据缓存功能以及密钥过期事件。@muntakim360,您找到解决方案了吗?我知道三年前有人问过这个问题,但现在仍然是:)你在使用任何特定的缓存库还是准备选择一个?@Leon我现在没有任何选择。任何东西都是健壮的、可用于生产的,并且具有基本的数据缓存功能以及密钥过期事件。@muntakim360,您找到解决方案了吗?我知道这个问题是3年前提出的,但仍然是:)