删除没用的文件
parent
cd2f5aa1e1
commit
290578d824
|
@ -8,7 +8,6 @@ using Panda.DynamicWebApi.Attributes;
|
|||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using IRaCIS.Core.Infra.Common.Cache;
|
||||
using Microsoft.Identity.Client;
|
||||
using static IRaCIS.Core.Domain.Share.StaticData;
|
||||
using IRaCIS.Core.Application.ViewModel;
|
||||
|
|
|
@ -10,6 +10,10 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
|
||||
namespace IRaCIS.Core.Infra.Common.Cache
|
||||
{
|
||||
/// <summary>
|
||||
/// 缓存类型
|
||||
/// </summary>
|
||||
public enum CacheType
|
||||
{
|
||||
/// <summary>
|
||||
/// 内存缓存
|
||||
/// </summary>
|
||||
Memory,
|
||||
/// <summary>
|
||||
/// Redis缓存
|
||||
/// </summary>
|
||||
Redis
|
||||
}
|
||||
}
|
|
@ -1,107 +0,0 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IRaCIS.Core.Infra.Common.Cache
|
||||
{
|
||||
/// <summary>
|
||||
/// 缓存接口
|
||||
/// </summary>
|
||||
public interface ICache
|
||||
{
|
||||
/// <summary>
|
||||
/// 用于在 key 存在时删除 key
|
||||
/// </summary>
|
||||
/// <param name="key">键</param>
|
||||
long Del(params string[] key);
|
||||
|
||||
/// <summary>
|
||||
/// 用于在 key 存在时删除 key
|
||||
/// </summary>
|
||||
/// <param name="key">键</param>
|
||||
/// <returns></returns>
|
||||
Task<long> DelAsync(params string[] key);
|
||||
|
||||
/// <summary>
|
||||
/// 用于在 key 模板存在时删除
|
||||
/// </summary>
|
||||
/// <param name="pattern">key模板</param>
|
||||
/// <returns></returns>
|
||||
Task<long> DelByPatternAsync(string pattern);
|
||||
|
||||
/// <summary>
|
||||
/// 检查给定 key 是否存在
|
||||
/// </summary>
|
||||
/// <param name="key">键</param>
|
||||
/// <returns></returns>
|
||||
bool Exists(string key);
|
||||
|
||||
/// <summary>
|
||||
/// 检查给定 key 是否存在
|
||||
/// </summary>
|
||||
/// <param name="key">键</param>
|
||||
/// <returns></returns>
|
||||
Task<bool> ExistsAsync(string key);
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定 key 的值
|
||||
/// </summary>
|
||||
/// <param name="key">键</param>
|
||||
/// <returns></returns>
|
||||
string Get(string key);
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定 key 的值
|
||||
/// </summary>
|
||||
/// <typeparam name="T">byte[] 或其他类型</typeparam>
|
||||
/// <param name="key">键</param>
|
||||
/// <returns></returns>
|
||||
T Get<T>(string key);
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定 key 的值
|
||||
/// </summary>
|
||||
/// <param name="key">键</param>
|
||||
/// <returns></returns>
|
||||
Task<string> GetAsync(string key);
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定 key 的值
|
||||
/// </summary>
|
||||
/// <typeparam name="T">byte[] 或其他类型</typeparam>
|
||||
/// <param name="key">键</param>
|
||||
/// <returns></returns>
|
||||
Task<T> GetAsync<T>(string key);
|
||||
|
||||
/// <summary>
|
||||
/// 设置指定 key 的值,所有写入参数object都支持string | byte[] | 数值 | 对象
|
||||
/// </summary>
|
||||
/// <param name="key">键</param>
|
||||
/// <param name="value">值</param>
|
||||
bool Set(string key, object value);
|
||||
|
||||
/// <summary>
|
||||
/// 设置指定 key 的值,所有写入参数object都支持string | byte[] | 数值 | 对象
|
||||
/// </summary>
|
||||
/// <param name="key">键</param>
|
||||
/// <param name="value">值</param>
|
||||
/// <param name="expire">有效期</param>
|
||||
bool Set(string key, object value, TimeSpan expire);
|
||||
|
||||
/// <summary>
|
||||
/// 设置指定 key 的值,所有写入参数object都支持string | byte[] | 数值 | 对象
|
||||
/// </summary>
|
||||
/// <param name="key">键</param>
|
||||
/// <param name="value">值</param>
|
||||
/// <returns></returns>
|
||||
Task<bool> SetAsync(string key, object value);
|
||||
|
||||
/// <summary>
|
||||
/// 设置指定 key 的值,所有写入参数object都支持string | byte[] | 数值 | 对象
|
||||
/// </summary>
|
||||
/// <param name="key">键</param>
|
||||
/// <param name="value">值</param>
|
||||
/// <param name="expire">有效期</param>
|
||||
/// <returns></returns>
|
||||
Task<bool> SetAsync(string key, object value, TimeSpan expire);
|
||||
}
|
||||
}
|
|
@ -1,127 +0,0 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
|
||||
namespace IRaCIS.Core.Infra.Common.Cache
|
||||
{
|
||||
/// <summary>
|
||||
/// 内存缓存
|
||||
/// </summary>
|
||||
public class MemoryCache : ICache
|
||||
{
|
||||
private readonly IMemoryCache _memoryCache;
|
||||
public MemoryCache(IMemoryCache memoryCache)
|
||||
{
|
||||
_memoryCache = memoryCache;
|
||||
}
|
||||
|
||||
public long Del(params string[] key)
|
||||
{
|
||||
foreach(var k in key)
|
||||
{
|
||||
_memoryCache.Remove(k);
|
||||
}
|
||||
return key.Length;
|
||||
}
|
||||
|
||||
public Task<long> DelAsync(params string[] key)
|
||||
{
|
||||
foreach (var k in key)
|
||||
{
|
||||
_memoryCache.Remove(k);
|
||||
}
|
||||
|
||||
return Task.FromResult((long)key.Length);
|
||||
}
|
||||
|
||||
public async Task<long> DelByPatternAsync(string pattern)
|
||||
{
|
||||
if (string.IsNullOrEmpty(pattern))
|
||||
return default;
|
||||
|
||||
pattern = Regex.Replace(pattern, @"\{.*\}", "(.*)");
|
||||
|
||||
var keys = GetAllKeys().Where(k => Regex.IsMatch(k, pattern));
|
||||
|
||||
if(keys != null && keys.Count() > 0)
|
||||
{
|
||||
return await DelAsync(keys.ToArray());
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
|
||||
public bool Exists(string key)
|
||||
{
|
||||
return _memoryCache.TryGetValue(key, out _);
|
||||
}
|
||||
|
||||
public Task<bool> ExistsAsync(string key)
|
||||
{
|
||||
return Task.FromResult(_memoryCache.TryGetValue(key, out _));
|
||||
}
|
||||
|
||||
public string Get(string key)
|
||||
{
|
||||
return _memoryCache.Get(key)?.ToString();
|
||||
}
|
||||
|
||||
public T Get<T>(string key)
|
||||
{
|
||||
return _memoryCache.Get<T>(key);
|
||||
}
|
||||
|
||||
public Task<string> GetAsync(string key)
|
||||
{
|
||||
return Task.FromResult(Get(key));
|
||||
}
|
||||
|
||||
public Task<T> GetAsync<T>(string key)
|
||||
{
|
||||
return Task.FromResult(Get<T>(key));
|
||||
}
|
||||
|
||||
public bool Set(string key, object value)
|
||||
{
|
||||
_memoryCache.Set(key, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Set(string key, object value, TimeSpan expire)
|
||||
{
|
||||
_memoryCache.Set(key, value, expire);
|
||||
return true;
|
||||
}
|
||||
|
||||
public Task<bool> SetAsync(string key, object value)
|
||||
{
|
||||
Set(key, value);
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
|
||||
public Task<bool> SetAsync(string key, object value, TimeSpan expire)
|
||||
{
|
||||
Set(key, value, expire);
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
|
||||
private List<string> GetAllKeys()
|
||||
{
|
||||
const BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic;
|
||||
var entries = _memoryCache.GetType().GetField("_entries", flags).GetValue(_memoryCache);
|
||||
var cacheItems = entries as IDictionary;
|
||||
var keys = new List<string>();
|
||||
if (cacheItems == null) return keys;
|
||||
foreach (DictionaryEntry cacheItem in cacheItems)
|
||||
{
|
||||
keys.Add(cacheItem.Key.ToString());
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,88 +0,0 @@
|
|||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IRaCIS.Core.Infra.Common.Cache
|
||||
{
|
||||
/// <summary>
|
||||
/// Redis缓存
|
||||
/// </summary>
|
||||
public class RedisCache : ICache
|
||||
{
|
||||
public long Del(params string[] key)
|
||||
{
|
||||
return RedisHelper.Del(key);
|
||||
}
|
||||
|
||||
public Task<long> DelAsync(params string[] key)
|
||||
{
|
||||
return RedisHelper.DelAsync(key);
|
||||
}
|
||||
|
||||
public async Task<long> DelByPatternAsync(string pattern)
|
||||
{
|
||||
if (string.IsNullOrEmpty(pattern))
|
||||
return default;
|
||||
|
||||
pattern = Regex.Replace(pattern, @"\{.*\}", "*");
|
||||
|
||||
var keys = (await RedisHelper.KeysAsync(pattern));
|
||||
if(keys != null && keys.Length > 0)
|
||||
{
|
||||
return await RedisHelper.DelAsync(keys);
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
|
||||
public bool Exists(string key)
|
||||
{
|
||||
return RedisHelper.Exists(key);
|
||||
}
|
||||
|
||||
public Task<bool> ExistsAsync(string key)
|
||||
{
|
||||
return RedisHelper.ExistsAsync(key);
|
||||
}
|
||||
|
||||
public string Get(string key)
|
||||
{
|
||||
return RedisHelper.Get(key);
|
||||
}
|
||||
|
||||
public T Get<T>(string key)
|
||||
{
|
||||
return RedisHelper.Get<T>(key);
|
||||
}
|
||||
|
||||
public Task<string> GetAsync(string key)
|
||||
{
|
||||
return RedisHelper.GetAsync(key);
|
||||
}
|
||||
|
||||
public Task<T> GetAsync<T>(string key)
|
||||
{
|
||||
return RedisHelper.GetAsync<T>(key);
|
||||
}
|
||||
|
||||
public bool Set(string key, object value)
|
||||
{
|
||||
return RedisHelper.Set(key, value);
|
||||
}
|
||||
|
||||
public bool Set(string key, object value, TimeSpan expire)
|
||||
{
|
||||
return RedisHelper.Set(key, value, expire);
|
||||
}
|
||||
|
||||
public Task<bool> SetAsync(string key, object value)
|
||||
{
|
||||
return RedisHelper.SetAsync(key, value);
|
||||
}
|
||||
|
||||
public Task<bool> SetAsync(string key, object value, TimeSpan expire)
|
||||
{
|
||||
return RedisHelper.SetAsync(key, value, expire);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,12 +10,12 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoMapper" Version="12.0.1" />
|
||||
<PackageReference Include="CSRedisCore" Version="3.8.671" />
|
||||
<PackageReference Include="EFCore.BulkExtensions" Version="7.1.6" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.12" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.12" />
|
||||
<PackageReference Include="EntityFrameworkCore.Exceptions.SqlServer" Version="6.0.3.2" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.12" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="SharpCompress" Version="0.34.1" />
|
||||
<PackageReference Include="SharpZipLib" Version="1.4.2" />
|
||||
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.3.5" />
|
||||
|
|
Loading…
Reference in New Issue