Search code examples
c#asp.netvisual-studiovisual-studio-2008proxy-classes

How to write a proxy with C#?


i have coding a web application which has multi user. they are select data or insert data every thing is that. But selecting some data need too many time such as using LINQ or mathematical calculation. i thing that: my user1 :

select * from MyTable -----> save as caching via proxy server in machine

my user2 :

select * from MyTable2 -----> save as caching via proxy server in machine

my user3 :

insert into MyTable2 -----> Update caching(select * from MyTable2) via proxy server in machine

How to write a proxy server to select Faster and update select result if another user update table?

enter image description here


Solution

  • I guess I understand what you mean. If you want to achieve the result shown on your drawing, then one way would be to have server cache all the data which is requested by any machine. I think this is too much overhead in terms of the memory, but you can accomplish this in many ways. For example, create a proxy class which handles all database calls and then caches the results. Whenever next call is done, the handler class checks the proxy and returns if such exists; if not, then it makes a call and adds results to the cache.

    BTW, I think this part is already taken into account by existing ORMs, no?