From 51e1cd1cb5343c0556cf17305f14f1a666145245 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Wed, 11 Oct 2017 14:26:16 +0800 Subject: [PATCH] Update Cache Demo --- Src/Asp.Net/ExtensionsDemo/CacheDemo.cs | 16 ++++++---------- .../SqlSugar.Extensions.DataCache/RedisCache.cs | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/Src/Asp.Net/ExtensionsDemo/CacheDemo.cs b/Src/Asp.Net/ExtensionsDemo/CacheDemo.cs index cc6ba1880..b369903d2 100644 --- a/Src/Asp.Net/ExtensionsDemo/CacheDemo.cs +++ b/Src/Asp.Net/ExtensionsDemo/CacheDemo.cs @@ -12,8 +12,8 @@ namespace ExtensionsDemo { public static void Init() { - HttpRuntimeCache(); - //RedisCache(); + //HttpRuntimeCache(); + RedisCache(); } @@ -63,7 +63,7 @@ namespace ExtensionsDemo } private static void RedisCache() { - ICacheService myCache = new RedisCache("localhost");//ICacheService + ICacheService myCache = new RedisCache("10.1.249.196");//ICacheService SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, @@ -76,18 +76,14 @@ namespace ExtensionsDemo }); - for (int i = 0; i < 10000; i++) - { - db.Queryable().Where(it => it.Id > 0).WithCache().ToList(); - } + db.Queryable().Where(it => it.Id > 0).WithCache(30).ToList(); - - db.Queryable((s1, s2) => s1.Id == s2.Id).Select(s1 => s1).WithCache().ToList(); + db.Queryable((s1, s2) => s1.Id == s2.Id).Select(s1 => s1).WithCache(30).ToList(); db.Queryable((s1, s2) => new object[] { JoinType.Left,s1.Id==s2.Id - }).Select(s1 => s1).WithCache().ToList(); + }).Select(s1 => s1).WithCache(30).ToList(); Console.WriteLine("Cache Key Count:" + myCache.GetAllKey().Count()); diff --git a/Src/Asp.Net/SqlSugar.Extensions.DataCache/RedisCache.cs b/Src/Asp.Net/SqlSugar.Extensions.DataCache/RedisCache.cs index 293072444..f5bd08449 100644 --- a/Src/Asp.Net/SqlSugar.Extensions.DataCache/RedisCache.cs +++ b/Src/Asp.Net/SqlSugar.Extensions.DataCache/RedisCache.cs @@ -162,7 +162,7 @@ namespace SqlSugar.Extensions { using (var client = _redisClientManager.GetClient()) { - return client.SearchKeys("SqlSugarDataCache"); + return client.SearchKeys("SqlSugarDataCache.*"); } } }