I would like to store a small list of objects and create a dependency to the website's start page. Thus enforcing cache invalidation when the start page is altered. This was easily done with the old cache implementation, which now is deprecated.
The documentation says I should be using the CacheEvictionPolicy class. But I can't figure out how to setup dependencies with this class.
My question is: How do one cache objects with dependencies to EPiServer content (IContent) in EPiServer 7.5 (without using deprecated methods and including the feature of invalidation messages between web servers)?
You should be able to use DataFactoryCache.CreateDependency() to create cache dependencies. It supports specifying a ContentReference as its parameter, for example ContentReference.StartPage to clear a cache entry when the start page is updated.
Also, much of this (albeit for EPiServer 6) is still valid: http://tedgustaf.com/blog/2010/5/cache-objects-in-episerver-with-page-dependencies/
Unless I'm misunderstanding what you need to achieve?
Edit: For EPiServer 7.5+ you should use CacheEvictionPolicy like:
EPiServer.CacheManager.Insert(
key,
item,
new CacheEvictionPolicy(
new List<string>() { DataFactoryCache.PageCommonCacheKey(dependencyLink) }
)
);