0

Background

In my project app, many small applications has been integrated and they have built-in different technologies such as

  • Angular JS 1.5
  • ASP.Net MVC
  • Angular 5

My app also uses AWS as cloud partner.

Problem

I need to implement Caching mechanism in my app. I am storing some values in S3 bucket and I am using API calls to pull the values. I want to keep those values in Cache. Since, it is implemented in multiple technologies (especially Angular and ASP.Net MVC), Does any caching mechanism can be used in common?

Observations

I have done some work on this and observed the following caching is available

  1. .NET MVC - In Memory Caching
  2. Angular - In Memory Cache with ReactJS

As AWS is my Cloud Partner, it is offering ElastiCache as a Web service, which supports MemCached and Redis. I am not clear whether this will behave like normal In-Memory Cache ( in ASP .NET Core) or this will refer database for caching and retrieve details (cause round-trip!) from there?

Question

Can anyone let me know best caching technique can be handled to my app for both .net mvc and angular?

Viswa
  • 745
  • 10
  • 30

1 Answers1

1

This is bit tricky (I am assuming that you are using multiple servers of memcache). When you use memcache a lot depends on the clients implementation. Your client decides, on which server a particular key will be stored. And the servers are unaware of the existences of the other servers.

As you are using different languages you will be using different clients so each client will be implementing its own algorithm to decide the server on which the key will be placed. So there will be cases where your client on Angular will store key "K1" on server "S1" and the .Net Client will store the same key on server "S2"

This will add another problem of invalidating these keys, as it will be needed to invalidate the key on both servers.

There is one more problem. You will have to store all objects in a json format if the keys are common. So that the keys is stored on the same memcache server will be read by all programing languages.

I think the best thing is to set a small enough time to invalidate keys on memcache (if it is feasible) and storing keys with different prefix or suffix for each client type. So .net client will store key K1 as 'K1-net' and the one with Angular will store it as "k1-ang".

I would also explore redis which might help (not sure)

pratikvasa
  • 1,897
  • 20
  • 24
  • Thanks for the update Pratik. In my application, we will store keys uniquely. So, .net and angular would NOThave same keys. I am also thinking about going to centralized or distributed cache. Also, my datastore response is in JSON format so cache will store objects only in JSON. Now, which one to pick? MemCached or Redis. For MemCached or Redis, do you have any idea on how to connect with .net and angular app? – Viswa May 31 '18 at 12:55
  • 1
    For .Net you can use [enyim cache](https://github.com/enyim/EnyimMemcached) and for angular am not sure but this should help https://www.npmjs.com/package/memcached – pratikvasa Jun 01 '18 at 04:30
  • Exactly what I analysed that you update! By now, I have no other option to go to Redis as there is no plug in for angular. But On the Other hand, MemCached has something to do with. will try that. – Viswa Jun 01 '18 at 05:44