5

Is it possible to retrieve HttpRuntime.Cache from another application?

i am having two applications ,

for example App-A, App-B

in App-A i am inserting values to cache

HttpRuntime.Cache.Insert(sCacheKey, sCacheValue, Nothing, Now.AddHours(CInt(System.Configuration.ConfigurationManager.AppSettings("CacheExpirationHours"))), TimeSpan.Zero)

I am not able to retrieve the values in App-B

Dim strList As String
strList = HttpRuntime.Cache.Get(sCacheKey)

it is simply returning as Nothing. what i am doing wrong?

Jay
  • 1,317
  • 4
  • 16
  • 40
  • 2
    HttpRuntime.Cache exists in the app domain, so no you can't access it from another app. You'll need to expose that cache via wcf, http, etc if you want another app to access it. Also consider using a distributed cache. – Jace Rhea Oct 15 '13 at 15:20
  • 1
    I think it's better to use Redis or Memcached. – Ahmed KRAIEM Oct 15 '13 at 15:22
  • 1
    Someone else asked this: http://stackoverflow.com/questions/1244105/sharing-an-httpruntime-cache-across-two-iis-applications – lex87 Oct 15 '13 at 15:25

1 Answers1

8

HttpRuntime.Cache exists in the app domain, so no you can't access it from another app. You'll need to expose that cache via wcf, web api, etc if you want another app to access it. Also consider using a distributed cache.

Jace Rhea
  • 4,982
  • 4
  • 36
  • 55