zoukankan      html  css  js  c++  java
  • appfabric 简单应用

    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 .WindowsSystem32AppFabric 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[1];
                servers[0] = new DataCacheServerEndpoint("sv1", 22233);
                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=20   });
                var user = (User)cache.Get("zy");
                Console.WriteLine(user.ToString());
    
                Console.ReadLine();
    
            }
        }
    }
  • 相关阅读:
    centos 7 安装vsftpd
    Goland 使用插件一键发布Docker到线上centos服务器
    Docker alpine 添加bash+修改时区发布镜像到docker.io
    centos 7 nginx 配置Let's Encrypt证书,并自动更新
    centos 7 源码方式安装nginx(1.16.1) + ssl + 阿里证书配置
    centos nginx 卸载
    influxdb time duration literal
    阿里云标准-Redis安全基线检查
    配置systemctl(zookeeper、hadoop、redis)
    【转】Hadoop2.7.7 API: yarn-site.xml 解析
  • 原文地址:https://www.cnblogs.com/zyip/p/3550863.html
Copyright © 2011-2022 走看看