如何用C#编写代理?
我正在编写一个具有多用户的网络应用程序。它们是选择数据或插入数据,一切都是如此。但是选择一些数据需要太多时间,例如使用LINQ或数学计算。我认为: 我的用户1:
select * from MyTable -----> save as caching via proxy server in machine
我的用户2:
select * from MyTable2 -----> save as caching via proxy server in machine
我的用户3:
insert into MyTable2 -----> Update caching(select * from MyTable2) via proxy server in machine
如何编写代理服务器来选择更快并在另一个用户更新表时更新选择结果?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想我明白你的意思了。如果您想实现绘图上显示的结果,那么一种方法是让服务器缓存任何计算机请求的所有数据。我认为这对于内存来说开销太大,但是您可以通过多种方式来实现这一点。例如,创建一个代理类来处理所有数据库调用,然后缓存结果。每当下一次调用完成时,处理程序类都会检查代理并返回(如果存在);如果没有,则它会进行调用并将结果添加到缓存中。
顺便说一句,我认为现有的 ORM 已经考虑到了这部分,不是吗?
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?
为什么你需要一个代理呢?
您想要实现的目标是使用 ADO Entity Framework 的好处之一。
网络上到处都有教程,但您可以开始 这个
ADO Entity Framework 足够智能,可以缓存多次使用的对象并在它们使用时刷新它们虽然不同步,但它们还具有一系列出色的属性,例如后期绑定和并发处理。
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.