Cache cache = GetCurrentCache(); LockHandle handle = new LockHandle(); Customer item = (Customer)cache.GetAndLock("C20081117005", new TimeSpan(0, 30, 0), out handle); Customer customer = new Customer() { ID = "C20081117005", FirstName = "Terry", LastName = "Lee", Age = 25, Email = "lhj_cauc[#AT#]163.com" }; cache.PutAndUnlock(customer.ID, customer, handle, null);
<section name="fabric" type="System.Data.Fabric.Common.ConfigFile, FabricCommon" allowLocation="true" allowDefinition="Everywhere"/>
<fabric> <section name="logging" path=""> <collection name="sinks" collectionType="list"> <customType className="System.Data.Fabric.Common.EventLogger,FabricCommon" sinkName="System.Data.Fabric.Common.ConsoleSink,FabricCommon" sinkParam="" defaultLevel="-1"/> <customType className="System.Data.Fabric.Common.EventLogger,FabricCommon" sinkName="System.Data.Fabric.Common.FileEventSink,FabricCommon" sinkParam="CacheClientLog" defaultLevel="1"/> <customType className="System.Data.Fabric.Common.EventLogger,FabricCommon" sinkName="System.Data.Caching.ETWSink, CacheBaseLibrary" sinkParam="" defaultLevel="-1" /> </collection> </section> </fabric>
private Cache GetCurrentCache() { List<LogSink> sinklist = new List<LogSink>(2); LogSink fileBasedSink = new LogSink(SinkType.FILE, TraceLevel.Warning, "DCache/dd-hh-mm"); LogSink consoleBasedSink = new LogSink(SinkType.CONSOLE, TraceLevel.Warning); sinklist.Add(fileBasedSink); sinklist.Add(consoleBasedSink); // 啓用 CacheFactory.CreateLogSinks(sinklist); // 禁用 CacheFactory.DisableLogSinks(); Cache dCache; ServerEndPoint[] servers = new ServerEndPoint[1]; servers[0] = new ServerEndPoint("localhost", 22233, "DistributedCacheService"); bool routingClient = true; bool localCache = false; var factory = new CacheFactory(servers, routingClient, localCache); dCache = factory.GetCache("default"); return dCache; }
CacheItem item = cache.GetCacheItem("Customers", "C2008");
CacheItem item = cache.GetCacheItem("Customers", "C2008");
((Customer)item.CacheObject).FirstName = "Huijun";
((Customer)item.CacheObject).FirstName = "Terry";
cache.Put("Customers", "C2008", item.CacheObject, item.Version);
<dcacheClient deployment="routing"> <localCache isEnabled="true" sync="TTLBased" ttlValue="300" /> <hosts> <host name="localhost" cachePort="22233" cacheHostName="DistributedCacheService"/> </hosts> </dcacheClient>
Cache dCache; ServerEndPoint[] servers = new ServerEndPoint[1]; servers[0] = new ServerEndPoint("localhost", 22233, "DistributedCacheService"); bool routingClient = true; bool localCache = false; var factory = new CacheFactory(servers, routingClient, localCache); dCache = factory.GetCache("default"); return dCache;
<dcacheClient deployment="routing"> <localCache isEnabled="true" sync="TTLBased" ttlValue="300" /> <hosts> <host name="localhost" cachePort="22233" cacheHostName="DistributedCacheService"/> </hosts> </dcacheClient>
Cache dCache; ServerEndPoint[] servers = new ServerEndPoint[1]; servers[0] = new ServerEndPoint("localhost", 22233, "DistributedCacheService"); bool routingClient = true; bool localCache = false; var factory = new CacheFactory(servers, routingClient, localCache); dCache = factory.GetCache("default"); return dCache;
0javascript
收藏css
Ctrl+Enter 發佈html
發佈java
取消mysql