當前位置: 首頁>>代碼示例>>C#>>正文


C# RedisClient.HDel方法代碼示例

本文整理匯總了C#中ServiceStack.Redis.RedisClient.HDel方法的典型用法代碼示例。如果您正苦於以下問題:C# RedisClient.HDel方法的具體用法?C# RedisClient.HDel怎麽用?C# RedisClient.HDel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ServiceStack.Redis.RedisClient的用法示例。


在下文中一共展示了RedisClient.HDel方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: RemoveWords

 public static void RemoveWords(RedisClient words)
 {
     Console.Write("Enter word for remove: ");
     string deleteWord = Console.ReadLine().ToLower();
     long countWords = words.HExists("words", Extensions.ToAsciiCharArray(deleteWord));
     if (countWords>0)
     {
         words.HDel("words", Extensions.ToAsciiCharArray(deleteWord));
     }
     else
     {
         Console.WriteLine("This word is not exist");
     }
 }
開發者ID:Gerya,項目名稱:TelerikAcademy,代碼行數:14,代碼來源:Utilities.cs

示例2: Main

    private static void Main()
    {
        // The default console's font doesn't support Cyrillic letters.
        // We should find a font with Unicode support and change the
        // default font.
        Console.OutputEncoding = Encoding.UTF8;
        ConsoleHelper.SetConsoleFont(6);

        string hashId = "dictionary";
        string word = "humongous";
        string synonym = "enormous";

        using (var redisClient = new RedisClient("127.0.0.1:6379"))
        {
            if (redisClient.Ping())
            {
                long entriesCount = redisClient.HExists(hashId, StringUtils.ToAsciiCharArray(word));

                if (entriesCount > 0)
                {
                    Console.WriteLine("This word is already in the dictionary.");
                }
                else
                {
                    redisClient.HSetNX(
                        hashId,
                        StringUtils.ToAsciiCharArray(word),
                        StringUtils.ToAsciiCharArray(synonym));

                    byte[] meaning = redisClient.HGet(hashId, StringUtils.ToAsciiCharArray(word));
                    Console.WriteLine(
                        "Word: {0}\nTranslation: {1}",
                        word,
                        StringUtils.StringFromByteArray(meaning));

                    redisClient.HDel(hashId, StringUtils.ToAsciiCharArray(word));
                }
            }
            else
            {
                Console.WriteLine("The Redis server isn't started.");
            }
        }
    }
開發者ID:nikolaynikolov,項目名稱:Telerik,代碼行數:44,代碼來源:RedisDictionaryDemo.cs

示例3: DoUpdateChangeKey

        private void DoUpdateChangeKey(RedisClient client, string setId, object keyByte, byte[] values, bool isHash, byte[] buffer)
        {
            string key = isHash
                ? Encoding.UTF8.GetString((byte[])keyByte)
                : keyByte.ToString();
            dynamic entity = null;
            try
            {
                entity = CovertEntityObject(key, values);
                CacheType cacheType = CacheType.None;
                if (entity != null)
                {
                    SchemaTable schema;
                    Type entityType = entity.GetType();
                    if (!EntitySchemaSet.TryGet(entityType, out schema))
                    {
                        EntitySchemaSet.InitSchema(entityType);
                    }
                    if (schema != null || EntitySchemaSet.TryGet(entityType, out schema))
                    {
                        cacheType = schema.CacheType;
                    }
                    if (cacheType != CacheType.None)
                    {
                        string redisKey = cacheType == CacheType.Dictionary
                            ? key.Split('|')[0]
                            : key.Split('_')[0];

                        using (IDataSender sender = DataSyncManager.GetRedisSender(schema, redisKey))
                        {
                            sender.Send(entity);

                        }
                    }

                }
            }
            catch (Exception ex)
            {
                TraceLog.WriteError("ChangeKey:{0} error:{1}", key, ex);
            }
            if (isHash)
            {
                client.HDel(setId, (byte[])keyByte);
            }
            else
            {
                client.ZRem(setId, buffer);
            }
            if (entity != null)
            {
                Type type = entity.GetType();
                string entityKey = string.Format("{0},{1}", key, type.Assembly.GetName().Name);
                client.HSet("__GLOBAL_SQL_CHANGE_KEYS_NEW", Encoding.UTF8.GetBytes(entityKey), new byte[] { 1 });
            }

        }
開發者ID:LeeWangyeol,項目名稱:Scut,代碼行數:57,代碼來源:CacheUpdateQueueForm.cs


注:本文中的ServiceStack.Redis.RedisClient.HDel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。