使用内存(比如性能)缓存数据集并将其与数据库更改绑定的最佳方式是什么?

时间:2022-02-02 20:05:56

Have anyone came across a opensource project or library in .Net to act as a caching layer between database and the aplication that automaticaly or on request sincronizes the data, so that performance could be improved.

是否有人在。net中遇到过一个开放源码项目或库,作为数据库和数据自动或按请求对数据进行编码的接口之间的缓存层,以便提高性能。

The .Net stack as some festures that can be used, like SqlDependencies and the Cache, but both have problems.

. net堆栈作为一些可以使用的形式,比如SqlDependencies和Cache,但是它们都有问题。

Tested alternatives:

测试的替代品:

  • SqlDependency are table based, so when one record on table is updated the whole table is invalidated.

    SqlDependency是基于表的,所以当表上的一条记录被更新时,整个表就失效了。

  • The Cache object works well but lack the object management features to manage the changes in objects.

    缓存对象工作得很好,但是缺少对象管理特性来管理对象中的更改。

  • DataTable's in Cache may be a solution, but i would like to deal with the cache as objects not DataRow's.
  • 缓存中的DataTable可能是一个解决方案,但我希望将缓存作为对象来处理,而不是DataRow的。

Any sugestions on system specialized in this task? Any good ORM that can do that?

对这个任务的系统有什么建议吗?有什么好的ORM可以做到吗?

2 个解决方案

#1


2  

You might want to have a look at AppFabric. One of its components is Velocity (which was a research in-memory distributed cache). It's only supported on server editions of Windows.

您可能想看看AppFabric。它的一个组成部分是Velocity(内存中的分布式缓存)。它只支持Windows的服务器版本。

#2


1  

OuputCaching is a very good way to optimize an application. Even just caching a page for 30sec makes a massive difference to an application under heavily load. VaryByCustom allows a great deal of control over how data is cached, as does the .NET output caching engine.

ouputcache是优化应用程序的一种非常好的方式。即使只缓存30秒的页面,对于负载严重的应用程序来说也会有很大的不同。VaryByCustom允许对数据如何缓存进行大量的控制,如。net输出缓存引擎。

If seeing real-time changes isn't critical, I'd suggest this as a possible alternative to keeping your data in memory, and even then I'd consider optimising specific pieces of data or objects. Keeping DataSets in memory doesn't scale - but of course it depends on your requirements. If you only have a small DataSet and can cache it in the Application cache then that's not such as bad idea.

如果看到实时更改并不重要,我建议将其作为将数据保存在内存中的一种可能的替代方法,即使这样,我也会考虑优化特定的数据或对象片段。将数据集保存在内存中是不可能的——当然,这取决于您的需求。如果您只有一个小型数据集,并且可以将它缓存到应用程序缓存中,那么这并不是一个坏主意。

#1


2  

You might want to have a look at AppFabric. One of its components is Velocity (which was a research in-memory distributed cache). It's only supported on server editions of Windows.

您可能想看看AppFabric。它的一个组成部分是Velocity(内存中的分布式缓存)。它只支持Windows的服务器版本。

#2


1  

OuputCaching is a very good way to optimize an application. Even just caching a page for 30sec makes a massive difference to an application under heavily load. VaryByCustom allows a great deal of control over how data is cached, as does the .NET output caching engine.

ouputcache是优化应用程序的一种非常好的方式。即使只缓存30秒的页面,对于负载严重的应用程序来说也会有很大的不同。VaryByCustom允许对数据如何缓存进行大量的控制,如。net输出缓存引擎。

If seeing real-time changes isn't critical, I'd suggest this as a possible alternative to keeping your data in memory, and even then I'd consider optimising specific pieces of data or objects. Keeping DataSets in memory doesn't scale - but of course it depends on your requirements. If you only have a small DataSet and can cache it in the Application cache then that's not such as bad idea.

如果看到实时更改并不重要,我建议将其作为将数据保存在内存中的一种可能的替代方法,即使这样,我也会考虑优化特定的数据或对象片段。将数据集保存在内存中是不可能的——当然,这取决于您的需求。如果您只有一个小型数据集,并且可以将它缓存到应用程序缓存中,那么这并不是一个坏主意。