0

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

3
  • 1
    I would suggest using a pre-existing caching solution instead of writing a new one from scratch Commented Mar 17, 2011 at 9:59
  • I don't know if this applies to your situation or if you just used a simplified example, but using WHERE clauses on your SELECT (and selecting only the required fields instead of *) might improve performance much more than manually caching the data. Remember that database access is usually very fast (when indexes are in the right places and you only request the data that is really needed) and that network connections between machines on the same subnet are usually fast as well. Did you do benchmarking to find out where your performance bottlenecks lie? Commented Mar 17, 2011 at 10:04
  • So you want something that keeps recently/frequently selected rows available in memory, and ensures that any updates that are made to the tables are reflected in those in memory rows, whilst dealing with memory pressure, etc? That sounds like what SQL Server is already doing internally (and doing a mighty fine job of it, most of the time). Commented Mar 17, 2011 at 10:29

2 Answers 2

1

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?

Sign up to request clarification or add additional context in comments.

2 Comments

i don't understand last sentence: "BTW, I think this part is already taken into account by existing ORMs, no?"
ORM = Object Relational Mapping. In simple words this is common name for Entity Framework, Linq To Sql, NHibernate. I guess they all already have this built-in into them right out of the box. oh, and BTW= By The Way :-)
0

Why would you want a Proxy for that?

What you want to accomplish is one of the benefits of use ADO Entity Framework

You have tutorials everywhere in the web, but you can start with this one

ADO Entity Framework is smart enough to cache objects that are used many times and refresh them when they are not in sync, they also have a series of fantastic properties like late-binding and concurrency handling.

3 Comments

balexandre; i think that you don't understand me. also i am a professional in entity framework.Thanks advise. but i don't want to re generate data i save select result in another machine
why will you wnat to handle one more machine (one more connection, one more license, one more everything) and not do things properly? ORM + Caching will work for you out of the box, no need to reinvent the wheel !
ok;) But i have to use linq to sql caching is ok in linqtosql?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.