使用微软分布式缓存服务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提供单机.主备.集群等丰富的实例类型,满足用户高读写性能及快速数据访问的业务诉求.支持丰富的实例管理操作,帮助用户省去运维烦恼.用户可以聚焦于业务逻辑本身,而无需过多考虑部署.监 ...
随机推荐
- arcgis gdb含下划线_和%的查询 by gisoracle
XMMC LIKE '%\_%' ESCAPE '\' by gisoracle 2015.1.25 XMMC LIKE '%\%%' escape '\' ...
- 重构6-Push Down Field(字段下移)
与上移字段相反的重构是下移字段.同样,这也是一个无需多言的简单重构. public abstract class Task { protected String _resolution; } publ ...
- ng-sortable-支持触屏的拖拽排序
1.首先是到https://github.com/a5hik/ng-sortable/tree/master/dist下载所需的文件:ng-sortable.min.js,ng-sortable.cs ...
- 怒刷DP之 HDU 1024
Max Sum Plus Plus Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- Linux 驱动分类 与访问技术
驱动开发概述 1.驱动分类 1.1 常规分析法 1.1.1 字符设备 字符设备是一种按字节来访问的设备,字符驱动则负责驱动字符设备, 这样的驱动通常实现open, close, read和wri ...
- Windows装机指南
开发相关: Anaconda整合了很多python的dependency,方便使用
- swift(一)
var floatNum:Float = 10.2 //浮点型 var double:Double = 10.3333 //双精度浮点型 var isSuccess:Bool = true //fal ...
- JDBC学习笔记(一)
public static void main(String[] args) { ResultSet rs = null; Statement stmt = null; Connection conn ...
- CCNA的RIP路由学习
rip(routing infomation protocol,路由信息协议) ,是一个纯粹的距离矢量路由选择协议,RIP每隔30s就将自己完整的路由选择表从所有激活的接口上送出.RIP只将跳计数作为 ...
- Cocos2d-JS中的Sprite精灵类
精灵类是cc.Sprite,它的类图如下图所示.cc.Sprite类直接继承了cc.Node类,具有cc.Node基本特征. 创建Sprite精灵对象 创建精灵对象可以使用构造函数实现,它们接受相同的 ...