Can you get instance of ICache and see if it is indeed CmsRunTimeCacheAdapter ?
I got the feedback, and it seems to be all working
Sample code
public void TestStaticallyCache(IObjectInstanceCache cache)
{
var cacheKey = "blahaKey";
cache.Insert(cacheKey, new object(), CacheEvictionPolicy.Empty);
SearchClient.Instance.Search<PageData>()
.StaticallyCacheFor(TimeSpan.FromDays(1000), null, cacheKey)
.GetContentResult();
SearchClient.Instance.Search<PageData>()
.StaticallyCacheFor(TimeSpan.FromDays(1000), null, cacheKey)
.GetContentResult();
cache.Remove(cacheKey);
cache.Insert(cacheKey, new object(), CacheEvictionPolicy.Empty);
SearchClient.Instance.Search<PageData>()
.StaticallyCacheFor(TimeSpan.FromDays(1000), null, cacheKey)
.GetContentResult();
}
@Quan Mai The above code will only function as intended (still with a 10-15 second delay), if there exists a valid cache entry prior to the FIND query
cache.Insert(cacheKey, new object(), CacheEvictionPolicy.Empty);
My initial belief was that by utilizing StaticallyCacheFor
with a cacheDependencyKey
and subsequently invalidating it during the PublishingContent
event, the FIND operation would automatically invalidate its own cache using the same key.
Now I looked into IObjectInstanceCache implementation in CMS 12 and it no longer requires the cache key to have existing object, like in 11. So it should just work. I suggest to contact developer service, maybe cc Karl and we can look into reproducing this issue.
In CMS 11 CacheDependency used to do the job for me
and invalidate the cache on PublishingContent event of the page
As CacheDependency is not supported in .Net Core/CMS12
my current code looks like this.NetCore
I am trying to invalidate the cache using the above code on the PublishingContent event but the FIND cache doesn't get invalidating. I have gone as far as removing all the FIND cache keys from MemeoryCache but still don't get the correct results.
Can someone help in solving this issue?