-2

I am using .NET Cache for WinForms application in C#. Application is directly connected to the remote database server (without any service layer) and the cache is maintained on client machine where application is installed.

Now I am making it to work on multiple machines on network and instances will be connected to the central database. Problem is that when one instance add record in database, other machines still contain the cache for old data.

I would need to know the possible solution to make this cache central for all application instances on network so when data is modified by one instance, cache will be refreshed for the rest of network nodes.

How can we implement the central cache for all application instances on network?

Umar Abbas
  • 4,399
  • 1
  • 18
  • 23
  • There are solutions which can help you to invalidate the client cache, for example using SignalR, SQL Dependency, Service Broker Queue, MSMQ, etc. But most likely, you will end up changing your application to use a service layer, you are looking for server side cache. – Reza Aghaei Feb 17 '20 at 21:42
  • Questions asking for best way are usually opinion based and off-topic. You may want to ask about some possible solutions. In addition, you need to explain about DBMS, the number of tables, your data access layer implementation, frequency of changes, the way that you implemented and invalidate the cache today, scale of application, authentication mechanism, limitations which stops to from having service layer, etc. – Reza Aghaei Feb 17 '20 at 21:47
  • Thank you for your suggestion, I have improved question. My database has hundreds of tables and updates are much frequent. application is simply a three tier and data access layer contains the calls to database where cache is maintained. I want to keep cache on client side so adding service layer is not feasible because I use SQL transactions on client side (UI layer where multiple calls are initialized) because each system access database directly. – Umar Abbas Feb 19 '20 at 13:07
  • *Updates are much frequent* → So the client cache will put a lot of pressure on the server and clients. – Reza Aghaei Feb 19 '20 at 15:52

1 Answers1

0

we had same issue and we implement the cache into the database.

(If you don't have any service Layer, you can use DB Layer Procedure or Trigger Etc..)

Firstly we made Cashe Table. for example CACHE_DATA.

And After machine(more than one) executes DML(Update, Insert, Delete Data), the Service Layer(or DB) Updates a Cache Data based on the newest Information. so that other Machines also can refer to that Table.

If DML executed too often, you can add "Last Cashing Time" Filed in CHACHE_DATA.

If(Last Cashing Time < Casing_Interval ) { Do Not Chasing } else { Cahsing }

  • We are caching information of many tables and each table has different structure. so how we keep all information in CACHE_DATA? if we use KeyValue structure then cost will be more then usual table I think. – Umar Abbas Feb 17 '20 at 06:27