RuoVea.ExCache
8.0.1
dotnet add package RuoVea.ExCache --version 8.0.1
NuGet\Install-Package RuoVea.ExCache -Version 8.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="RuoVea.ExCache" Version="8.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RuoVea.ExCache" Version="8.0.1" />
<PackageReference Include="RuoVea.ExCache" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add RuoVea.ExCache --version 8.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: RuoVea.ExCache, 8.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package RuoVea.ExCache@8.0.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=RuoVea.ExCache&version=8.0.1
#tool nuget:?package=RuoVea.ExCache&version=8.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
RuoVea.ExCache
介绍
缓存帮助类库
1、快速入门
通过Nuget安装组件
Install-Package RuoVea.ExCache
2、使用示例
// 写入值
bool bolset = ExCache.CacheOptions.CaChe.Write("demo", "assadasdasdasdasdasas");
// 获取值
var getValue = ExCache.CacheOptions.CaChe.Read("demo");
// 获取值无则用表达式写入
CacheFactery.CaChe.Cof_ReadWrite<string>("permission_142307070910551", () => { return "获取值"; }, new TimeSpan(3));
3、所有接口方法
/// <summary>
/// 从缓存里取数据,如果不存在则执行查询方法,
/// </summary>
/// <typeparam name="T">类型</typeparam>
/// <param name="key">键值</param>
/// <param name="GetFun">查询方法</param>
/// <param name="timeSpanMin">有效期 单位分钟</param>
/// <returns></returns>
T Cof_ReadWrite<T>(string key, Func<T> GetFun, TimeSpan timeSpanMin) where T : class;
#region Del
/// <summary>
/// 用于在 key 存在时删除 key
/// </summary>
/// <param name="key">键</param>
/// <returns>long</returns>
long Del(params string[] key);
/// <summary>
/// 用于在 key 存在时删除 key
/// </summary>
/// <param name="key">键</param>
/// <returns>long</returns>
Task<long> DelAsync(params string[] key);
/// <summary>
/// 用于在 key 模板存在时删除 删除带该前缀的数据
/// </summary>
/// <param name="pattern">pattern为前缀key: pattern* , 含有pattern的key: *pattern*</param>
/// <returns>bool</returns>
Task<long> DelByProfixAsync(string pattern);
#endregion
#region Exists
/// <summary>
/// 检查给定 key 是否存在
/// </summary>
/// <param name="key">键</param>
/// <returns>bool</returns>
bool Exists(string key);
/// <summary>
/// 检查给定 key 是否存在
/// </summary>
/// <param name="key">键</param>
/// <returns>bool</returns>
Task<bool> ExistsAsync(string key);
#endregion
#region Read
/// <summary>
/// 获取指定 key 的值
/// </summary>
/// <param name="key">键</param>
/// <returns>string</returns>
string Read(string key);
/// <summary>
/// 获取指定 key 的值
/// </summary>
/// <typeparam name="T">byte[] 或其他类型</typeparam>
/// <param name="key">键</param>
/// <returns>T</returns>
T Read<T>(string key);
/// <summary>
/// 获取指定 key 的值
/// </summary>
/// <param name="key">键</param>
/// <returns>string</returns>
Task<string> ReadAsync(string key);
/// <summary>
/// 获取指定 key 的值
/// </summary>
/// <typeparam name="T">byte[] 或其他类型</typeparam>
/// <param name="key">键</param>
/// <returns>T</returns>
Task<T> ReadAsync<T>(string key);
#endregion
#region Write
/// <summary>
/// 设置指定 key 的值,所有写入参数object都支持string | byte[] | 数值 | 对象
/// </summary>
/// <param name="key">键</param>
/// <param name="value">值</param>
/// <returns>bool</returns>
bool Write(string key, object value);
/// <summary>
/// 设置指定 key 的值,所有写入参数object都支持string | byte[] | 数值 | 对象
/// </summary>
/// <param name="key">键</param>
/// <param name="value">值</param>
/// <param name="expire">有效期</param>
/// <returns>bool</returns>
bool Write(string key, object value, TimeSpan expire);
/// <summary>
/// 设置指定 key 的值,所有写入参数object都支持string | byte[] | 数值 | 对象
/// </summary>
/// <param name="key">键</param>
/// <param name="value">值</param>
/// <returns>bool</returns>
Task<bool> WriteAsync(string key, object value);
/// <summary>
/// 设置指定 key 的值,所有写入参数object都支持string | byte[] | 数值 | 对象
/// </summary>
/// <param name="key">键</param>
/// <param name="value">值</param>
/// <param name="expire">有效期</param>
/// <returns>bool</returns>
Task<bool> WriteAsync(string key, object value, TimeSpan expire);
#endregion
4、相关配置文件
{
/* 缓存配置 */
"Cache": {
"Prefix": "RuoVea", /* 前缀 */
"CacheType": "MemoryCache", // RedisCache、MemoryCache
"RedisConnectionString": "127.0.0.1:6379,password=,defaultDatabase=2"
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- CSRedisCore (>= 3.8.803)
- Microsoft.Extensions.Caching.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Caching.Memory (>= 8.0.0)
- RuoVea.ExConfig (>= 8.0.0.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on RuoVea.ExCache:
Package | Downloads |
---|---|
RuoVea.ExSugar
Sqlsugar扩展 快速注入,支持简体中文、繁体中文、粤语、日语、法语、英语.使用方式:service.AddSqlsugar();继承RestFulLog 重写异常日志,操作日志,差异日志 |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
8.0.1 | 350 | 4/23/2025 |
8.0.0 | 959 | 8/28/2024 |
7.0.1 | 369 | 4/23/2025 |
7.0.0 | 1,156 | 8/28/2024 |
6.0.6 | 479 | 4/23/2025 |
6.0.5.3 | 5,293 | 3/13/2024 |
6.0.5.2 | 174 | 1/27/2024 |
6.0.5.1 | 254 | 11/18/2023 |
6.0.4 | 1,008 | 9/16/2022 |
6.0.3 | 518 | 4/14/2022 |
6.0.2 | 506 | 4/13/2022 |
6.0.1 | 489 | 4/13/2022 |
6.0.0 | 639 | 2/9/2022 |
5.0.5 | 191 | 4/23/2025 |
5.0.4.1 | 269 | 8/28/2024 |
5.0.4 | 644 | 11/19/2021 |
5.0.3 | 551 | 11/5/2021 |
5.0.2 | 439 | 11/4/2021 |
5.0.1 | 509 | 9/30/2021 |
5.0.0 | 485 | 9/28/2021 |