2

Basically, I have two separate applications lets they be AppA and AppB. I have implemented the cache feature available in

 "Microsoft.Practices.EnterpriseLibrary.Caching.dll" and "Microsoft.Practices.EnterpriseLibrary.Common.dll".

I want a cache to be added using AppA

 var cacheManager = CacheFactory.GetCacheManager();
 cacheManager.Add("SharedData","Data from AppA");

now, i want the next application "AppB" to retrieve this value

 var cacheManager = CacheFactory.GetCacheManager();
 var data = cacheManager.GetData("SharedData");

is it possible as these application runs in different application domain. If not can anybody suggest me any other alternative to achieve this behavior?

Liam
  • 27,717
  • 28
  • 128
  • 190
  • Might use serialized data shared between tcp, or No SQL database - all depends on your needs. – Vladimir Feb 08 '17 at 10:13
  • is there any examples currently available if so can you please share it with me ? – ShresthaGanesh Feb 08 '17 at 10:15
  • https://www.codeproject.com/Articles/12893/TCP-IP-Chat-Application-Using-C Chat application based on tcp. – Vladimir Feb 08 '17 at 10:20
  • You can share data between applications running in the same *process* but different *domains* by using `MarshalByRefObject`s to wrap the access, but such a solution will stop working the moment you start splitting up things into processes. – Jeroen Mostert Feb 08 '17 at 10:32
  • What kind of application is this? Web app, windows app, something else? – Liam Feb 08 '17 at 10:33
  • Use Distributed cache like Redis. That would clearly be the easiest solution. You can also use abstractions to not deal with the Redis client directly, Like http://cachemanager.net – MichaC Feb 09 '17 at 11:13

1 Answers1

3

You should explore distributed caching, which will allow you to access cache across multiple applications. Redis is one such caching provider. There are multiple .Net clients available to access Redis cache. StackExchange.Redis is one such client. You can read more about it here StackExcange .Net Redis client and here you can find details on how to install Redis on Windows

Community
  • 1
  • 1
Vinod
  • 1,882
  • 2
  • 17
  • 27
  • Agree, although i`d still consider tcp connection as an option. – Vladimir Feb 08 '17 at 10:22
  • Using distributed cache is the correct answer ;) Don't ever try to build that yourself with custom TCP (why?) connections. you can also use abstractions to not deal with the Redis client directly, Like http://cachemanager.net – MichaC Feb 09 '17 at 11:11