What is the best way to cache a dataset with memor

2019-05-10 02: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.

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

Tested alternatives:

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

  • 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.

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

2条回答
可以哭但决不认输i
2楼-- · 2019-05-10 03:26

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.

查看更多
走好不送
3楼-- · 2019-05-10 03:26

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.

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.

查看更多
登录 后发表回答