去除BloomFilter
This commit is contained in:
parent
8568e7c406
commit
0d077bea34
@ -12,7 +12,6 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AspectCore.Abstractions" Version="2.4.0" />
|
||||
<PackageReference Include="BloomFilter.CSRedis.NetCore" Version="2.1.1" />
|
||||
<PackageReference Include="Caching.CSRedis" Version="3.8.670" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="7.0.12" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="7.0.0" />
|
||||
|
||||
@ -3,7 +3,6 @@ using Infrastructure.Converter;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using NLog.Web;
|
||||
using System.Text.Json;
|
||||
using BloomFilter.CSRedis.Configurations;
|
||||
using Microsoft.Extensions.Caching.Distributed;
|
||||
using Microsoft.Extensions.Caching.Redis;
|
||||
using Microsoft.Extensions.Options;
|
||||
@ -69,18 +68,6 @@ if (openRedis == "1")
|
||||
{
|
||||
RedisServer.Initalize();
|
||||
builder.Services.AddSingleton<IDistributedCache>(new CSRedisCache(RedisHelper.Instance));
|
||||
builder.Services.AddBloomFilter(setupAction =>
|
||||
{
|
||||
setupAction.UseCSRedis(new FilterCSRedisOptions
|
||||
{
|
||||
Name = "Redis1",
|
||||
RedisKey = "BloomFilter",
|
||||
ConnectionStrings = new List<string>
|
||||
{
|
||||
AppSettings.GetConfig("RedisServer:Cache")
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,39 +1,24 @@
|
||||
using BloomFilter;
|
||||
using ZR.Infrastructure.Cache;
|
||||
using ZR.Infrastructure.Cache;
|
||||
|
||||
namespace ZR.ServiceCore.SqlSugar
|
||||
{
|
||||
public class SqlSugarCache : ICacheService
|
||||
{
|
||||
private readonly IBloomFilter _bloomFilter;
|
||||
|
||||
public SqlSugarCache(IBloomFilter bloomFilter)
|
||||
{
|
||||
_bloomFilter = bloomFilter;
|
||||
}
|
||||
|
||||
public void Add<V>(string key, V value)
|
||||
{
|
||||
RedisServer.Cache.Set(key, value, 3600 + RedisHelper.RandomExpired(5, 30));
|
||||
// CacheHelper.SetCache(key, value);
|
||||
_bloomFilter.Add(key);
|
||||
}
|
||||
|
||||
public void Add<V>(string key, V value, int cacheDurationInSeconds)
|
||||
{
|
||||
RedisServer.Cache.Set(key, value, cacheDurationInSeconds);
|
||||
// CacheHelper.SetCaches(key, value, cacheDurationInSeconds);
|
||||
_bloomFilter.Add(key);
|
||||
}
|
||||
|
||||
public bool ContainsKey<V>(string key)
|
||||
{
|
||||
if (_bloomFilter.Contains(key))
|
||||
{
|
||||
return RedisServer.Cache.Exists(key);
|
||||
}
|
||||
|
||||
return false;
|
||||
return RedisServer.Cache.Exists(key);
|
||||
// return CacheHelper.Exists(key);
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using BloomFilter;
|
||||
using Infrastructure;
|
||||
using Infrastructure;
|
||||
using Infrastructure.Model;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
@ -36,8 +35,7 @@ namespace ZR.ServiceCore.SqlSugar
|
||||
});
|
||||
}
|
||||
SugarIocServices.AddSqlSugar(iocList);
|
||||
var provider = services.BuildServiceProvider();
|
||||
ICacheService cache = new SqlSugarCache(provider.GetService<IBloomFilter>());
|
||||
ICacheService cache = new SqlSugarCache();
|
||||
SugarIocServices.ConfigurationSugar(db =>
|
||||
{
|
||||
var u = App.User;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user