http://msdn.microsoft.com/en-us/library/ee790941(v=azure.10).aspx

Preparing the Visual Studio Project
http://msdn.microsoft.com/en-us/library/ee790876(v=azure.10).aspx

To initialize and start your cache cluster:
Use-CacheCluster
New-Cache
Grant-CacheAllowedClientAccount
Start-CacheCluster

Open your Visual Studio .NET project.
In Solution Explorer, right-click the project name and then select Add Reference.
Select the Browse tab of the Add Reference dialog.
Navigate to the .\Windows\System32\AppFabric directory.
Add a reference to the following two assemblies: Microsoft.ApplicationServer.Caching.Client.dll and Microsoft.ApplicationServer.Caching.Core.dll.
Optionally, add the using statement (Imports in Visual Basic) at the top of the code files to reference the Microsoft.ApplicationServer.Caching namespace.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; using Microsoft.ApplicationServer.Caching; namespace AppFabricCaching
{
class Program
{
[Serializable]
class User
{
public string name;
public string gender;
public int age; public override string ToString()
{
return "name:" + name + System.Environment.NewLine +
"gender:" + gender + System.Environment.NewLine +
"age:" + age.ToString();
}
}
static void Main(string[] args)
{ //To configure a cache client programmatically
DataCacheServerEndpoint[] servers = new DataCacheServerEndpoint[];
servers[] = new DataCacheServerEndpoint("sv1", );
DataCacheFactoryConfiguration factoryConfig = new DataCacheFactoryConfiguration();
factoryConfig.Servers = servers;
// Create a configured DataCacheFactory object.
DataCacheFactory mycacheFactory = new DataCacheFactory(factoryConfig);
// Get a cache client for the cache "NamedCache1".
DataCache myDefaultCache = mycacheFactory.GetCache("NamedCache1"); var cache = myDefaultCache;
cache.Add("zy", new User() { name="zy", gender="m", age= });
var user = (User)cache.Get("zy");
Console.WriteLine(user.ToString()); Console.ReadLine(); }
}
}

appfabric 简单应用的更多相关文章

  1. Windows Server AppFabric 安装文档

    安装指南 入门标题页 3 Windows Server AppFabric 安装和配置指南 3 版权 3 版权所有 3 简介 3 清单:规划安装 4 硬件要求 4 使计算机作好安装准备 5 本节内容 ...

  2. 浅谈Windows Server APPFABRIC

    hi,everyone !真的是好久好久没有update blog了,因为最近忙着备考,没有时间对<数据结构与算法>进行研究学习了.所以,blog一直未更新.today is Friday ...

  3. Windows Server AppFabric分布式缓存研究

    分享一则先前对Windows Server AppFabric分布式缓存的技术研究. 一. AppFabric 技术架构和原理 AppFabric与Memcached类似,采用C/S的模式,在 ser ...

  4. 【造轮子】打造一个简单的万能Excel读写工具

    大家工作或者平时是不是经常遇到要读写一些简单格式的Excel? shit!~很蛋疼,因为之前吹牛,就搞了个这东西,还算是挺实用,和大家分享下. 厌烦了每次搞简单类型的Excel读写?不怕~来,喜欢流式 ...

  5. Fabio 安装和简单使用

    Fabio(Go 语言):https://github.com/eBay/fabio Fabio 是一个快速.现代.zero-conf 负载均衡 HTTP(S) 路由器,用于部署 Consul 管理的 ...

  6. node.js学习(三)简单的node程序&&模块简单使用&&commonJS规范&&深入理解模块原理

    一.一个简单的node程序 1.新建一个txt文件 2.修改后缀 修改之后会弹出这个,点击"是" 3.运行test.js 源文件 使用node.js运行之后的. 如果该路径下没有该 ...

  7. 哪种缓存效果高?开源一个简单的缓存组件j2cache

    背景 现在的web系统已经越来越多的应用缓存技术,而且缓存技术确实是能实足的增强系统性能的.我在项目中也开始接触一些缓存的需求. 开始简单的就用jvm(java托管内存)来做缓存,这样对于单个应用服务 ...

  8. 在Openfire上弄一个简单的推送系统

    推送系统 说是推送系统有点大,其实就是一个消息广播功能吧.作用其实也就是由服务端接收到消息然后推送到订阅的客户端. 思路 对于推送最关键的是服务端向客户端发送数据,客户端向服务端订阅自己想要的消息.这 ...

  9. 我的MYSQL学习心得(一) 简单语法

    我的MYSQL学习心得(一) 简单语法 我的MYSQL学习心得(二) 数据类型宽度 我的MYSQL学习心得(三) 查看字段长度 我的MYSQL学习心得(四) 数据类型 我的MYSQL学习心得(五) 运 ...

随机推荐

  1. 深入浅出js中的this(一)

    Q:this是什么? A:this是Javascript语言的一个关键字,它代表函数运行时,自动生成的一个内部对象,在每个 function 中自动根据作用域(scope) 确定, 指向的是此次调用者 ...

  2. 西门子PLC两线制,四线制

    1 一.对于控制系统模块:两线制,四线制信号都只有两根线接入模件,区别在于: 两线制信号的这两根线一正一负,不带提供信号电流,而且提供供电电压:一般流量,压力,液位等等的信号常用两线制信号,但也要根据 ...

  3. Windows2012中Jenkins搭建.NET自动编译测试与发布环境

    安装7Zip 下载地址: http://www.7-zip.org/a/7z1602-x64.exe 安装Git 下载地址:https://github.com/git-for-windows/git ...

  4. jquery checkbox全选,全不选,反选方法,jquery checkbox全选只能操作一次

    jquery checkbox全选,全不选,反选方法, jquery checkbox全选只能操作一次, jquery checkbox全选只有第一次成功 >>>>>&g ...

  5. php处理字符串常用函数

    1查找字符位置函数: strpos($str,search,[int]):查找search在$str中的第一次位置从int开始: stripos($str,search,[int]):函数返回字符串在 ...

  6. js限制文本框只能输入数字

    JS判断只能是数字和小数点1.文本框只能输入数字代码(小数点也不能输入) <input onkeyup="this.value=this.value.replace(/\D/g,'') ...

  7. 【转】prototype扩展的JavaScript常用函数库

    Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> ...

  8. Checkbox 全选、反选

    1.全选.反选 <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></t ...

  9. .NET和JSON

    JSON(JavaScript Object Notation)已经成为了现在大多数程序间数据交换的存储格式,在很多地方取代了XML文件的位置.JSON实际就是JavaScript的对象数组. .NE ...

  10. sgu 105 Div 3

    一个数能整除3当且仅当各位数之和能整除3. 有了这个规律就好办了, 但是呢,仔细一看, n太大了, 都到 2^31 了.所以简单的模拟肯定不行. 这种貌似像数论的题,一时找不到好办法,就打表! 打表出 ...