初始化

This commit is contained in:
2025-11-21 08:48:01 +08:00
commit b4d684a84c
202 changed files with 28585 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ZiggyCreatures.FusionCache" Version="2.4.0" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,41 @@
using ZiggyCreatures.Caching.Fusion;
namespace MyFunctioncache
{
internal class Program
{
static void Main(string[] args)
{
var entryOptions = new FusionCacheEntryOptions().SetDuration(TimeSpan.FromMinutes(10));
// 创建缓存实例
var cache = new FusionCache(new FusionCacheOptions()
{
DefaultEntryOptions = new FusionCacheEntryOptions
{
Duration = TimeSpan.FromMinutes(5) // 默认缓存5分钟
}
});
// 设置缓存值
cache.Set("product_123", new PersonInfo {UserName="aaa"});
// 获取缓存值
var product = cache.TryGet<PersonInfo>("product_123");
// 删除缓存项
cache.Remove("product_123");
Console.WriteLine("Hello, World!");
}
}
public class PersonInfo
{
public string UserName { get; set; }
public int Age { get; set; }
public string Nationality { get; set; }
public string CacheMsg { get; set; }
}
}