标签:style blog http ar io color os 使用 sp
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="dcache" type="System.Data.Caching.DCacheSection,
CacheBaseLibrary, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=89845dcd8080cc91" />
</configSections>
<dcache cluster="localhost" size="Small">
<caches>
<cache type="partitioned" consistency="strong" name="default">
<policy>
<eviction type="lru" />
<expiration defaultTTL="10" isExpirable="true" />
</policy>
</cache>
<cache type="partitioned" consistency="strong" name="other">
<policy>
<eviction type="lru" />
<expiration defaultTTL="10" isExpirable="true" />
</policy>
</cache>
</caches>
<hosts>
<host clusterPort="22234" hostId="1319514812" size="1024" quorumHost="true"
name="TERRYLEE-PC" cacheHostName="DistributedCacheService"
cachePort="22233" />
</hosts>
<advancedProperties>
<partitionStoreConnectionSettings providerName="System.Data.SqlServerCe.3.5"
connectionString="D:\CacheShare\ConfigStore.sdf" />
</advancedProperties>
</dcache>
</configuration>
<section name="dcacheClient"
type="System.Data.Caching.DCacheSection,
CacheBaseLibrary, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
<dcacheClient>
<localCache isEnabled="true" sync="TTLBased" ttlValue="300" />
<hosts>
<host name="localhost" cachePort="22233"
cacheHostName="DistributedCacheService"/>
</hosts>
</dcacheClient>
[Serializable]
public class Customer
{
public String ID { get; set; }
public String FirstName { get; set; }
public String LastName { get; set; }
public int Age { get; set; }
public String Email { get; set; }
}
Cache cache = GetCurrentCache();
Customer customer = new Customer()
{
ID = "C20081117002",
FirstName = "Terry",
LastName = "Lee",
Age = 25,
Email = "lhj_cauc[#AT#]163.com"
};
cache.Add(customer.ID, customer);
Cache cache = GetCurrentCache();
Customer customer = cache.Get("C20081117002") as Customer;
Cache cache = GetCurrentCache();
cache.Remove("C20081117002");
Cache cache = GetCurrentCache();
Customer customer = new Customer()
{
ID = "C20081117002",
FirstName = "Huijui",
LastName = "Li",
Age = 26,
Email = "lhj_cauc[#AT#]163.com"
};
cache["C20081117002"] = customer;
Cache cache = GetCurrentCache();
Customer customer = new Customer()
{
ID = "C20081117002",
FirstName = "Huijui",
LastName = "Li",
Age = 26,
Email = "lhj_cauc[#AT#]163.com"
};
cache.Put(customer.ID, customer);
public void ClearRegion(string region);
public bool CreateRegion(string region, bool evictable);
public bool RemoveRegion(string region);
Cache cache = GetCurrentCache();
string regionName = "Customers";
cache.CreateRegion(regionName, false);
Customer customer = new Customer()
{
ID = "C20081117003",
FirstName = "Terry",
LastName = "Lee",
Age = 25,
Email = "lhj_cauc[#AT#]163.com"
};
cache.Add(regionName, customer.ID, customer);
Cache cache = GetCurrentCache();
string regionName = "Customers";
Customer customer1 = new Customer()
{
ID = "C20081117004",
FirstName = "Terry",
LastName = "Lee",
Age = 25,
Email = "lhj_cauc[#AT#]163.com"
};
Customer customer2 = new Customer()
{
ID = "C20081117005",
FirstName = "Terry",
LastName = "Lee",
Age = 25,
Email = "lhj_cauc[#AT#]163.com"
};
Tag tag1 = new Tag("Beijing");
Tag tag2 = new Tag("Tianjin");
cache.Add(regionName, customer1.ID, customer1, new Tag[] { tag1, tag2 });
cache.Add(regionName, customer2.ID, customer2, new Tag[] { tag2 });
GetAllMatchingTags(string region, Tag[] tags)
GetAnyMatchingTag(string region, Tag[] tags)
GetByTag(string region, Tag tag)
string regionName = "Customers";
Tag[] tags = new Tag[] { new Tag("Beijing"),
new Tag("Tianjin")};
List<KeyValuePair<string, object>> result
= cache.GetAllMatchingTags(regionName, tags);
<section name="dcacheClient"
type="System.Data.Caching.DCacheSection,
CacheBaseLibrary, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
<dcacheClient>
<localCache isEnabled="true" sync="TTLBased" ttlValue="300" />
<hosts>
<host name="localhost" cachePort="22233"
cacheHostName="DistributedCacheService"/>
</hosts>
</dcacheClient>
<sessionState mode="Custom" customProvider="Velocity">
<providers>
<add name="Velocity"
type="System.Data.Caching.SessionStoreProvider,ClientLibrary"
cacheName="default"/>
</providers>
</sessionState>
本文出自 “TerryLee技术专栏” 博客,请务必保留此出处http://terrylee.blog.51cto.com/342737/151964
使用微软分布式缓存服务Velocity(Windows Server AppFabric Caching Service)
标签:style blog http ar io color os 使用 sp
原文地址:http://www.cnblogs.com/andrew_927/p/4172230.html