本文介绍了NHibernate的哪个缓存用于WinForms应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个后端数据库(Oracle)的一个C#WinForms应用程序和使用的NHibernate的O / R映射。我想,以减少传播到数据库尽可能因为在这里的网络是很慢,所以我读到第二级缓存。我发现,其中列出了以下可用缓存实现



我想知道的我应该用我的应用程序



的缓存应该是简单的,它不应该显著减慢查询的第一次出现,它不应该花太多的内存加载执行程序集。 (!随着NHibernate和城堡,应用程序已经占用了80 MB的RAM)



My considerations so far were:

  • Velocity seems quite heavyweight and overkill (the files totally take 467 KB of disk space, haven't measured the RAM it takes so far because I didn't manage to make it run, see below)
  • Prevalence, at least in my first attempt, slowed down my query from ~0.5 secs to ~5 secs, and caching didn't work (see below)
  • SysCache seems to be for ASP.NET, not for winforms.
  • MemCache and SharedCache seem to be for distributed scenarios.

Which one would you suggest me to use? There would also be a built-in implementation, which of course is very lightweight, but the referenced article tells me that I "(...) should never use this cache provider for production code but only for testing."

Besides the question which fits best into my situation I also faced problems with applying them:

  • Velocity complained that "dcacheClient" tag not specified in the application configuration file. Specify valid tag in configuration file," although I created an app.config file for the assembly and pasted the example from this article.

  • Prevalence, as mentioned above, heavily slowed down my first query, and the next time the exact same query was executed, another select was sent to the database. Maybe I should "externalize" this topic into another post. I will do that if someone tells me it is absolutely unusual that a query is slowed down so much and he needs further details to help me.

解决方案

SysCache uses the "ASP.NET" cache only because it's the only one included with .NET 2.x/3.x (.NET 4 includes a separate System.Runtime.Caching assembly)

It can be used in desktop applications without any problems (I'm using it right now), and it requires almost no configuration.

Now, your memory considerations seem to be a little off with this century. No machine has shipped with less than 1GB in the past years, and most have between 2GB and 8GB, so 80MB is essentially nothing. The browser in which I'm writing this takes 220MB.

The very essence of caching is about using a resource (usually memory, disk in very particular cases) to reduce the usage of a slower one (network)

这篇关于NHibernate的哪个缓存用于WinForms应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 20:02