本文整理汇总了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()));
}
}
示例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;
}
示例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));
}
}
}
示例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);
}
示例5: DemoSetup
private static void DemoSetup(IDatabase cache)
{
cache.KeyDelete("i");
}
示例6: ActuallyDeleteKey
private void ActuallyDeleteKey(IDatabase database, RedisKey key)
{
_logger.Debug("Deleting {RedisKey}", key);
database.KeyDelete(key);
}
示例7: Delete
public static void Delete(IDatabase database, string id)
{
database.KeyDelete(new RedisKey[] { id, GetHashKey(id) });
}
示例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");
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
}
}