优势在一个asp.net应用程序中使用缓存的缺点是什么?缓存、应用程序、缺点、优势

2023-09-07 04:04:41 作者:你若对我真心实意

有哪些优点和一个asp.net应用程序中使用缓存的缺点是什么?

What are the advantages and disadvantages of using caching in an asp.net application?

推荐答案

答案将根据环境和技术而有所不同。

Answers will vary based on Environments and Technology.

优点

在减少对Web服务/数据库负载 在提高性能 可靠性(假设数据库备份缓存。服务器宕机和DB被缓存的支持,没有时间浪费在内存中缓存重新填充的)

缺点

可能会遇到同步缓存问题 增加维护 可扩展性问题

随着大国意味着巨大的责任)。我们碰到了,我们决定使用HttpContext.Cache(坏主意),在分发应用程序的问题。早在该项目的人认为只是扔在那里,我们没有遇到问题,直到我们去住。每当谈到缓存,你需要看大局。扪心自问,我们是否有足够的数据,足够的用户,或认股权证实现缓存性能要求?

With great power comes great responsibility ;). We ran into an issue where we decided to use the HttpContext.Cache (bad idea) in an application that was distributed. Early on in the project someone deemed to just throw it in there and we didn't run into issues until we went live. Whenever it comes to caching you need to look at the big picture. Ask yourself do we have enough Data, enough Users, or a performance requirement that warrants implementing caching?

如果你回答是,那么你可能会需要一个服务器农场,选择你的缓存提供者明智。

If you answer yes then you are probably going to need a farm of servers so choose your caching provider wisely.

使用所有这样说,微软有一个新的缓存API的AppFabric /速度,你可以利用处理缓存的分配和同步自动神奇。

With all that being said, Microsoft has a new cache API AppFabric/Velocity that you could leverage that handles the distribution and syncing of the cache auto-magically.

AppFabric缓存可以让你做超时驱逐,甚至建在通知驱逐,从而为您的数据的机会缓存服务器会采用它不并定期与服务器缓存客户端检查,并得到的东西的清单,它需要同步。

AppFabric caching allows you to do time out eviction, or even built in notification eviction, so as your data chances the caching server takes not of it and periodically the cache client checks in with the server and gets a list of stuff it needs to sync.