使用微软分布式缓存服务Velocity(Windows Server AppFabric Caching Service)
概述
配置模型
<?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);
ASP.NET SessionState提供者
<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)的更多相关文章
- Windows Server AppFabric分布式缓存研究
分享一则先前对Windows Server AppFabric分布式缓存的技术研究. 一. AppFabric 技术架构和原理 AppFabric与Memcached类似,采用C/S的模式,在 ser ...
- 如何用分布式缓存服务实现Redis内存优化
Redis是一种支持Key-Value等多种数据结构的存储系统,其数据特性是“ALL IN MEMORY”,因此优化内存十分重要.在对Redis进行内存优化时,先要掌握Redis内存存储的特性比如字符 ...
- 误解了Windows Server AppFabric
想为自己的流程引擎找一个宿主,选择了几套方案,想先从AppFabric开始,原因主要出于以下几点: 1. 自己用过Windows Service或Form作为一些定时任务等应用的宿主,但苦于学艺不精, ...
- Windows Server AppFabric 安装文档
安装指南 入门标题页 3 Windows Server AppFabric 安装和配置指南 3 版权 3 版权所有 3 简介 3 清单:规划安装 4 硬件要求 4 使计算机作好安装准备 5 本节内容 ...
- 浅谈Windows Server APPFABRIC
hi,everyone !真的是好久好久没有update blog了,因为最近忙着备考,没有时间对<数据结构与算法>进行研究学习了.所以,blog一直未更新.today is Friday ...
- SharePoint 2013 必备组件之 Windows Server AppFabric 安装错误
1.如下图,在使用SharePoint2013产品准备工具的时候,网上下载安装Windows Server AppFabric的时候,报错,点击完成重启计算机,重新安装依然报错. 2.无奈之下,只有选 ...
- Windows Server AppFabric
文章:Windows Server AppFabric简介 介绍了AppFabric强大的功能.
- 微软分布式缓存 appfabric
appfabric为微软自家产的分布式缓存解决方案,随dotnet4.0一起发布.目前版本为1.1
- 华为云分布式缓存服务DCS与开源服务差异对比
华为云分布式缓存DCS提供单机.主备.集群等丰富的实例类型,满足用户高读写性能及快速数据访问的业务诉求.支持丰富的实例管理操作,帮助用户省去运维烦恼.用户可以聚焦于业务逻辑本身,而无需过多考虑部署.监 ...
随机推荐
- [Windows] VS2010代码模板添加版权信息
通过以下方式可以自定义CS类文件代码模板(以下为VS2010,VS2008类似): 1,打开VS的安装目录,例如 D:\Program Files\Microsoft Visual Studio 10 ...
- 【Android 界面效果17】Android手机平板两不误,使用Fragment实现兼容手机和平板的程序
记得我之前参与开发过一个华为的项目,要求程序可以支持好几种终端设备,其中就包括Android手机和Android Pad.然后为了节省人力,公司无节操地让Android手机和Android Pad都由 ...
- 关于Navicat Premium导入xlsx的问题
这段时间由于工作需要,频繁通过Oracle导入/导出大量数据,测试了很多软件,都不理想.PL/SQL Developer导入.导出都卡死:Oracle SQL Developer也是导入.导出都卡的半 ...
- C++构造/析构/赋值函数
在编写C++程序的时候,我们会为特定某一类对象申明类类型,几乎我们申明的每一个class都会有一个或多个构造函数.一个析构函数.一个赋值运算符重载=.以及拷贝构造函数.这些函数控制着类对象的基础操作, ...
- Shodan!
Shodan! 简介 首先先介绍一下Shodan CNNMoney的一篇文章写道,虽然目前人们都认为谷歌是最强劲的搜索引擎,但Shodan才是互联网上最可怕的搜索引擎. 与谷歌不同的是,Shodan不 ...
- poj动态规划列表
[1]POJ 动态规划题目列表 容易: 1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 1189, 1208, 1276, 13 ...
- 【ERROR】---Error executing "adb devices":ADB server didn't ACK
搭建环境 ionic emulate android 的时候出现问题 端口占用,找到占用端口的程序,结束进程再启动 重新ionic emulate android 还是报错,闪了一下说fail ...
- 利用Form()使绘图可以不消失
1: public Form1() 2: { 3: InitializeComponent(); 4: this.Show(); 5: Graphics grp = this.CreateGraphi ...
- Ubuntu 16.04 Vysor 破解 和黑屏问题解决+ 闪屏问题解决
最新破解更新说明: 参考本人blog: 点我呀 黑屏解决 Vysor使用和黑屏问题 经过了一段时间的艰辛探索,确定是我chrome的PNaCl没有安装,然后又是一段艰辛的Google之后,终于在一个链 ...
- shell语法基础
一.变量 1.linux大小写敏感,变量取名要注意大小写.可以通过变量名前面加$来访问变量的内容.可以通过使用read命令来将用户输入的值赋给一个变量. 2.给变量赋值时,如果字符串中包含空格,就必须 ...