gpt4 book ai didi

c# - 关于win应用程序c#中的缓存数据

转载 作者:太空狗 更新时间:2023-10-29 22:24:23 24 4
gpt4 key购买 nike

在 asp.net 中缓存数据非常容易。所以我只想知道如何在 win 应用程序中缓存数据。

假设我想从 employee 表中获取和缓存数据,每当在 employee 表中插入或更新任何记录时,都会在我的表单中触发一个事件,然后我将从那里再次从 employee 表中重新加载这些数据并缓存它。在 asp.net 应用程序中很容易实现,但是如何在 win 应用程序中实现这个概念。我不想使用计时器。请帮我构想一下?

最佳答案

如果您可以面向 .NET 4,那么您应该看看 System.Runtime.Caching命名空间,以及 MemoryCache特别是类:

The MemoryCache class is similar to the ASP.NET Cache class. The MemoryCache class has many properties and methods for accessing the cache that will be familiar to you if you have used the ASP.NET Cache class. The main differences between the Cache and MemoryCache classes are that the MemoryCache class has been changed to make it usable by .NET Framework applications that are not ASP.NET applications. For example, the MemoryCache class has no dependencies on the System.Web assembly. Another difference is that you can create multiple instances of the MemoryCache class for use in the same application and in the same AppDomain instance.

关于c# - 关于win应用程序c#中的缓存数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5155473/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com