当前位置: 首页>>代码示例>>C#>>正文


C# IDatabase.KeyDelete方法代码示例

本文整理汇总了C#中IDatabase.KeyDelete方法的典型用法代码示例。如果您正苦于以下问题:C# IDatabase.KeyDelete方法的具体用法?C# IDatabase.KeyDelete怎么用?C# IDatabase.KeyDelete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDatabase的用法示例。


在下文中一共展示了IDatabase.KeyDelete方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DemoSetup

        private static void DemoSetup(IDatabase cache)
        {
            // Need to wait until the shard (nodes) in the cluster are discovered. This is an issue with the client: https://github.com/StackExchange/StackExchange.Redis/issues/300
            Thread.Sleep(500);

            for (int i = 0; i < 20; i++)
            {
                cache.KeyDelete(clusterKey + i.ToString());
                cache.KeyDelete(clusterAllCustomersKey.Replace("id", i.ToString()));
                cache.KeyDelete(clusterCustomerOrderKey.Replace("id", i.ToString()));
                cache.KeyDelete(clusterCustomersWithOrders.Replace("id", i.ToString()));
            }
        }
开发者ID:bibhaspaul,项目名称:RedisSamples,代码行数:13,代码来源:Clustering.cs

示例2: Delete

        public override bool Delete(object obj, Type objType, IDatabase redisDatabase, string id, PropertyInfo basePropertyInfo = null)
        {
            var setKey = new RedisKeyObject(basePropertyInfo, id);

            redisDatabase.KeyDelete(setKey.RedisKey);

            return true;
        }
开发者ID:DemgelOpenSource,项目名称:DemgelRedis,代码行数:8,代码来源:SetHandler.cs

示例3: DemoSetup

        private static void DemoSetup(IDatabase cache)
        {
            cache.KeyDelete(RedisLists.redisKey);
            // Using tags to cross-correlate cached items
            RedisLists.tags = new List<string[]>()
            {
                new string[] { "iot","csharp" },
                new string[] { "iot","azure","csharp" },
                new string[] { "csharp","git","big data" },
                new string[] { "iot","git","database" },
                new string[] { "database","git" },
                new string[] { "csharp","database" },
                new string[] { "iot" },
                new string[] { "iot","database","git" },
                new string[] { "azure","database","big data","git","csharp" },
                new string[] { "azure" }
            };

            RedisLists.posts = new List<BlogPost>();
            int blogKey = 0;
            int blogPostId = 0;
            int numberOfPosts = 20;
            Random random = new Random();
            for (int i = 0; i < numberOfPosts; i++)
            {
                blogPostId = blogKey++;
                posts.Add(new BlogPost(
                    blogPostId,               // Blog post ID
                    string.Format(CultureInfo.InvariantCulture, "Blog Post #{0}",
                        blogPostId),          // Blog post title
                    random.Next(100, 10000),  // Ranking score
                    tags[i % tags.Count]));   // Tags – assigned from a collection 
                // in the tags list
            }

            foreach (BlogPost post in posts)
            {
                string redisKey = string.Format(CultureInfo.InvariantCulture,
                    "blog:posts:{0}:tags", post.Id);
                // Add tags to the blog post in redis
                cache.KeyDelete(redisKey);

                // Now do the inverse so we can figure how which blog posts have a given tag.
                foreach (var tag in post.Tags)
                {
                    cache.KeyDelete(string.Format(CultureInfo.InvariantCulture,
                        "tag:{0}:blog:posts", tag));
                }
            }
        }
开发者ID:bibhaspaul,项目名称:RedisSamples,代码行数:50,代码来源:RedisLists.cs

示例4: TestConcurrent

 private static void TestConcurrent(IDatabase db, RedisKey key, int SyncLoop, int Threads)
 {
     long value;
     db.KeyDelete(key, CommandFlags.FireAndForget);
     var time = RunConcurrent(delegate
     {
         for (int i = 0; i < SyncLoop; i++)
         {
             db.StringIncrement(key);
         }
     }, Threads, timeout: 45000);
     value = (long)db.StringGet(key);
     Assert.AreEqual(SyncLoop * Threads, value);
     Console.WriteLine("Sync: {0} INCR using {1} threads, {2:###,##0}ms, {3} ops/s; final value: {4}",
         SyncLoop * Threads, Threads,
         (long)time.TotalMilliseconds,
         (long)((SyncLoop * Threads) / time.TotalSeconds),
         value);
 }
开发者ID:ninjaferret,项目名称:StackExchange.Redis,代码行数:19,代码来源:SSL.cs

示例5: DemoSetup

 private static void DemoSetup(IDatabase cache)
 {
     cache.KeyDelete("i");
 }
开发者ID:bibhaspaul,项目名称:RedisSamples,代码行数:4,代码来源:KeySpaceNotifications.cs

示例6: ActuallyDeleteKey

 private void ActuallyDeleteKey(IDatabase database, RedisKey key)
 {
     _logger.Debug("Deleting {RedisKey}", key);
     database.KeyDelete(key);
 }
开发者ID:NimbusAPI,项目名称:Nimbus,代码行数:5,代码来源:NamespaceCleanser.cs

示例7: Delete

 public static void Delete(IDatabase database, string id)
 {
     database.KeyDelete(new RedisKey[] { id, GetHashKey(id) });
 }
开发者ID:jango2015,项目名称:Distributed,代码行数:4,代码来源:RedisSessionStateStoreProvider.cs

示例8: DemoSetup

 private static void DemoSetup(IDatabase cache)
 {
     cache.KeyDelete("i1");
     cache.KeyDelete("i2");
     cache.KeyDelete("i3");
     cache.KeyDelete("i:1");
     cache.KeyDelete("i:2");
     cache.KeyDelete("i:3");
     cache.KeyDelete("i:t1");
     cache.KeyDelete("i:t2");
 }
开发者ID:bibhaspaul,项目名称:RedisSamples,代码行数:11,代码来源:GeneralConcepts.cs

示例9: InvalidateItem

        public void InvalidateItem(string key)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }
            _database = _redis.GetDatabase();

            key = HashKey(key);

            lock (_lock) 
            {
                try 
                {
                    var entry = _database.Get<CacheEntry>(key);

                    if (entry == null) return;

                    _database.KeyDelete(key);

                    foreach (var set in entry.EntitySets) {
                        _database.SetRemove(GetEntitySetKey(set), key);
                    }
                } 
                catch (Exception e) 
                {
                    OnCachingFailed(e);
                }
            }
        }
开发者ID:GlenConway,项目名称:EFCache.Redis,代码行数:30,代码来源:RedisCache.cs

示例10: InvalidateSets

        public void InvalidateSets(IEnumerable<string> entitySets)
        {
            if (entitySets == null)
            {
                throw new ArgumentNullException("entitySets");
            }
            _database = _redis.GetDatabase();
            
            var itemsToInvalidate = new HashSet<string>();

            lock (_lock)
            {
                try 
                {
                    foreach (var entitySet in entitySets) {
                        var entitySetKey = GetEntitySetKey(entitySet);
                        var keys = _database.SetMembers(entitySetKey).Select(v => v.ToString());
                        itemsToInvalidate.UnionWith(keys);
                        _database.KeyDelete(EntitySetKey);
                    }
                } 
                catch (Exception e) 
                {
                    OnCachingFailed(e);
                    return;
                }

                foreach (var key in itemsToInvalidate)
                {
                    InvalidateItem(key);
                }
            }
        }
开发者ID:GlenConway,项目名称:EFCache.Redis,代码行数:33,代码来源:RedisCache.cs

示例11: InvalidateItem

        public void InvalidateItem(string key)
        {
            key.GuardAgainstNullOrEmpty(nameof(key));
            
            _database = _redis.GetDatabase();

            key = HashKey(key);

            lock (_lock) 
            {
                try 
                {
                    var entry = _database.Get<CacheEntry>(key);

                    if (entry == null) return;

                    _database.KeyDelete(key, CommandFlags.FireAndForget);

                    foreach (var set in entry.EntitySets) {
                        _database.SetRemove(AddCacheQualifier(set), key, CommandFlags.FireAndForget);
                    }
                } 
                catch (Exception e) 
                {
                    OnCachingFailed(e);
                }
            }
        }
开发者ID:silentbobbert,项目名称:EFCache.Redis,代码行数:28,代码来源:RedisCache.cs

示例12: InvalidateSets

        public void InvalidateSets(IEnumerable<string> entitySets)
        {
            // ReSharper disable once PossibleMultipleEnumeration - the guard clause should not enumerate, its just checking the reference is not null
            entitySets.GuardAgainstNull(nameof(entitySets));
            
            _database = _redis.GetDatabase();
            
            var itemsToInvalidate = new HashSet<string>();

            lock (_lock)
            {
                try 
                {
                    // ReSharper disable once PossibleMultipleEnumeration - the guard clause should not enumerate, its just checking the reference is not null
                    foreach (var entitySet in entitySets) {
                        var entitySetKey = AddCacheQualifier(entitySet);
                        var keys = _database.SetMembers(entitySetKey).Select(v => v.ToString());
                        itemsToInvalidate.UnionWith(keys);
                        _database.KeyDelete(entitySetKey, CommandFlags.FireAndForget);
                    }
                } 
                catch (Exception e) 
                {
                    OnCachingFailed(e);
                    return;
                }

                foreach (var key in itemsToInvalidate)
                {
                    InvalidateItem(key);
                }
            }
        }
开发者ID:silentbobbert,项目名称:EFCache.Redis,代码行数:33,代码来源:RedisCache.cs


注:本文中的IDatabase.KeyDelete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。