开发者

Is there a built-in in-memory, LRU cache for Silverlight?

开发者 https://www.devze.com 2023-02-19 20:14 出处:网络
Is there a bu开发者_运维知识库ilt-in in-memory, LRU cache for Silverlight? I can write my own from scratch, but I would rather have one built by the pros.The Caching Application Block is included in E

Is there a bu开发者_运维知识库ilt-in in-memory, LRU cache for Silverlight? I can write my own from scratch, but I would rather have one built by the pros.


The Caching Application Block is included in Enterprise Library for Silverlight.

InMemoryCache is in Microsoft.Practices.EnterpriseLibrary.Caching.Silverlight.dll.

var cache = new InMemoryCache("cache", 100, 50, TimeSpan.FromSeconds(1));

var item = new object();
cache.Add("key", item, DateTimeOffset.Now.AddSeconds(1));

var cachedItem = cache.Get("key");
Assert.AreSame(item, cachedItem);

Thread.Sleep(TimeSpan.FromSeconds(5));
Assert.IsNull(cache.Get("key"));
0

精彩评论

暂无评论...
验证码 换一张
取 消