Is it possible to get the expiry DateTime of an HttpRuntime.Cache object?
If so, what would be the best approach?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I just went through the System.Web.Caching.Cache in reflector. It seems like everything that involves the expiry date is marked as internal. The only place i found public access to it, was through the Cache.Add and Cache.Insert methods.
So it looks like you are out of luck, unless you want to go through reflection, which I wouldn’t recommend unless you really really need that date.
But if you wish to do it anyway, then here is some code that would do the trick:
Since .NET 4.5 the internal public getter of the
HttpRuntime.Cachewas replaced with a static variant and thus you will need to invoke/get the static variant: