In my ASP.NET web site I persist objects retrieved from DB for some time and make sure that the only single instance of object is created per DB record.
I also use [InstanceCache] to cache calculated value for one of business objects, object is kept in cache for the duration of user session.
Today, though, I came across the use-case when I would like to invalidate cached value.
How can I do this for properties that are cached using [InstanceCache]?
Please advise.
Thank you.
I think you may be able to do that by using one of the
ClearCachestatic methods of theCacheAspectclass, that allow clearing the cache at different levels of granularity:If you want to clear the cache only for the specific
[InstanceCache]property, you will need to get itsMethodInfo(for the "get" method of the property I think) using reflection and pass that along to the first variant.This seems to work for regular
[Cache]attribute annotations, so if clearing the cache for[InstanceCache]items is at all supported, this would be the route to go.