亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Redis For .NET開源組件Beetle.Redis

發布時間:2020-06-23 20:30:22 來源:網絡 閱讀:500 作者:ikende 欄目:編程語言

       Beetle.Redis是一款開源的Redis Client for .net組件,它提供非常簡便的操作方式可以讓開發人員輕松地訪問Redis,同時提供json和protobuf的數據格式支持.基于連接池的默認訪問方式可以讓開發人員簡潔高效地訪問redis同時,而不必關心線程和連接同步等一系列復雜的事情.

配置

組件在使用前要進行配置,主要用于描述訪問Redis的信息,分別是讀寫服務表列.

<configSections>
  <section name="redisClientSection" type="Beetle.Redis.RedisClientSection, Beetle.Redis, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
</configSections>
<redisClientSection dB="0"  xmlns="urn:Beetle.Redis">
  <writes>
    <add host="192.168.0.105" connections="9"/>
  </writes>
  <reads>
    <add host="192.168.0.105" connections="9"/>
  </reads>
</redisClientSection>

以上分別配置讀/寫服務地址,默認開啟的連接數是9個,訪問數據庫是0;根據實際應用的需要讀/寫都可以配置多個redis服務信息.

使用

組件的使用非常簡單,在使用前并不需要象其他redis client組件一樣定義連接信息,組件在缺省的情況下會自動使用 redisClientSection的配置環境去操作相應的Redis服務.

  • String Get/Set

    StringKey key = "HENRY";
    string Remark = "henryfan gz cn 18 henryfan@msn.com 28304340";
    key.Set(Remark);
    Assert.AreEqual(Remark, key.Get<string>());


  • Json Get/Set

    JsonKey rk = "henry_json";
    UserBase ub = new UserBase();
    ub.Name = "henryfan";
    ub.City = "gz";
    ub.Counrty = "cn";
    ub.Age = 10;
    rk.Set(ub);
    Assert.AreEqual(ub.Name, rk.Get<UserBase>().Name);


  • Protobuf Get/Set

    ProtobufKey rk = "henry_protobuf";
    UserBase ub = new UserBase();
    ub.Name = "henryfan";
    ub.City = "gz";
    ub.Counrty = "cn";
    ub.Age = 10;
    rk.Set(ub);
    Assert.AreEqual(ub.Name, rk.Get<UserBase>().Name);


  • List

    [TestMethod]
    public void LST_POP_PUSH()
    {
        ProtobufList<UserBase> lst = "USERS";
        lst.Push(new UserBase { Name = "henry", Age = 18, City = "gz", Counrty = "cn" });
        Assert.AreEqual("henry", lst.Pop().Name);
    }
    [TestMethod]
    public void LST_REMOVE_ADD()
    {
        ProtobufList<UserBase> lst = "USERS";
        lst.Add(new UserBase { Name = "henry", Age = 18, City = "gz", Counrty = "cn" });
        lst.Add(new UserBase { Name = "bbq", Age = 18, City = "gz", Counrty = "cn" });
        Assert.AreEqual("bbq", lst.Remove().Name);
    }
    [TestMethod]
    public void LST_Length()
    {
        ProtobufList<UserBase> lst = "USERS";
        lst.Clear();
        lst.Add(new UserBase { Name = "henry", Age = 18, City = "gz", Counrty = "cn" });
        lst.Add(new UserBase { Name = "bbq", Age = 18, City = "gz", Counrty = "cn" });
        Assert.AreEqual(lst.Count(), 2);
    }
    [TestMethod]
    public void LST_Region()
    {
        ProtobufList<UserBase> lst ="USERS";
        lst.Clear();
        for (int i = 0; i < 10; i++)
        {
            lst.Add(new UserBase { Name = "henry" + i, Age = 18, City = "gz", Counrty = "cn" });
        }
        IList<UserBase> items = lst.Range();
        Assert.AreEqual(items[0].Name, "henry0");
        Assert.AreEqual(items[9].Name, "henry9");
        items = lst.Range(5, 7);
        Assert.AreEqual(items[0].Name, "henry5");
        Assert.AreEqual(items[2].Name, "henry7");
    }


  • MapSet

    [TestMethod]
    public void MapSet()
    {
        JsonMapSet map = "HENRY_INFO";
        UserBase ub = new UserBase();
        ub.Name = "henryfan";
        ub.City = "gz";
        ub.Counrty = "cn";
        ub.Age = 10;
        Contact contact = new Contact();
        contact.EMail = "hernyfan@msn.com";
        contact.QQ = "28304340";
        contact.Phone = "13660223497";
        map.Set(ub, contact);
        IList<object> data = map.Get<UserBase, Contact>();
        Assert.AreEqual(ub.Name, ((UserBase)data[0]).Name);
        Assert.AreEqual(contact.Phone, ((Contact)data[1]).Phone);
    }
    [TestMethod]
    public void MapSetdRemove()
    {
        JsonMapSet map = "HENRY_INFO";
        UserBase ub = new UserBase();
        ub.Name = "henryfan";
        ub.City = "gz";
        ub.Counrty = "cn";
        ub.Age = 10;
        Contact contact = new Contact();
        contact.EMail = "hernyfan@msn.com";
        contact.QQ = "28304340";
        contact.Phone = "13660223497";
        map.Set(ub, contact);
        map.Remove<Contact>();
        contact = map.Get<Contact>();
        Assert.AreEqual(null, contact);
    }
    [TestMethod]
    public void MapSetClear()
    {
        JsonMapSet map = "HENRY_INFO";
        UserBase ub = new UserBase();
        ub.Name = "henryfan";
        ub.City = "gz";
        ub.Counrty = "cn";
        ub.Age = 10;
        Contact contact = new Contact();
        contact.EMail = "hernyfan@msn.com";
        contact.QQ = "28304340";
        contact.Phone = "13660223497";
        map.Set(ub, contact);
        map.Clear();
        IList<object> data = map.Get<UserBase, Contact>();
        Assert.AreEqual(null, data[0]);
        Assert.AreEqual(null, data[1]);
    }


性能

Redis For .NET開源組件Beetle.Redis

Sample

Redis For .NET開源組件Beetle.Redis

下載

Beetle.Redis 0.6

NorthWind Sample

Source Project



向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

纳雍县| 彰化县| 苗栗县| 平江县| 高雄县| 高平市| 乐亭县| 九台市| 大兴区| 锡林郭勒盟| 法库县| 天镇县| 鹿泉市| 开阳县| 临沂市| 鄂托克前旗| 喀喇| 谷城县| 望都县| 措勤县| 鲁山县| 安国市| 全州县| 特克斯县| 洛阳市| 普兰县| 麦盖提县| 克山县| 射洪县| 富川| 桓仁| 博湖县| 科尔| 银川市| 临潭县| 浪卡子县| 东丽区| 石渠县| 自治县| 永胜县| 龙江县|