Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programming the Cache API. namespace Microsoft.ApplicationServer.Caching { public sealed class DataCacheFactory : IDisposable { public DataCacheFactory();

Similar presentations


Presentation on theme: "Programming the Cache API. namespace Microsoft.ApplicationServer.Caching { public sealed class DataCacheFactory : IDisposable { public DataCacheFactory();"— Presentation transcript:

1 Programming the Cache API

2

3

4

5 namespace Microsoft.ApplicationServer.Caching { public sealed class DataCacheFactory : IDisposable { public DataCacheFactory(); public DataCacheFactory( DataCacheFactoryConfiguration configuration); public void Dispose(); public DataCache GetCache( string cacheName); public DataCache GetDefaultCache(); }

6 DataCacheFactoryConfiguration

7 element --> <section name="dataCacheClient" type="Microsoft.ApplicationServer.Caching.DataCacheClientSection, Microsoft.ApplicationServer.Caching.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

8

9 public DataCacheItemVersion Add(string key, object value); public DataCacheItemVersion Add(string key, object value, TimeSpan timeout); public DataCacheItemVersion Put(string key, object value); public DataCacheItemVersion Put(string key, object value, TimeSpan timeout); Parameterdescription keyKey of item in the distributed cache valueValue of object stored in the cache (serialized) timeoutHow long before the item should expire

10

11 //create DataCacheFactory based on config file var dcf = new DataCacheFactory(); //get the cache named "TestCache" var cache = dcf.GetCache("TestCache"); //Add an item called "Test" - throws if exists cache.Add("Test", new Data {TheData = "Test" }); //Put an item called "Test2" - overwrites if exists cache.Put("Test2", new Data { TheData = "Test2" }); //Get "Test3" - add if not in cache (cache-aside) var test3 = cache.Get("Test3") as Data; if (test3 == null) { test3 = new Data {TheData = "Test3" }; cache.Add("Test3", test3); }

12

13

14

15

16

17 element --> <section name="dataCacheClient" type="Microsoft.ApplicationServer.Caching.DataCacheClientSection, Microsoft.ApplicationServer.Caching.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> <localCache isEnabled="true" sync="TimeoutBased" objectCount="100000" ttlValue="300" />

18

19


Download ppt "Programming the Cache API. namespace Microsoft.ApplicationServer.Caching { public sealed class DataCacheFactory : IDisposable { public DataCacheFactory();"

Similar presentations


Ads by Google