refactor(storage): 重构存储接口实现

- 将FileStorage类的接口从IStorage改为IFileStorage
- 添加IFileStorage接口定义,继承自IStorage接口
- 将ScopedStorage类的接口从IStorage改为IScopedStorage
- 添加IScopedStorage接口定义,继承自IStorage接口
- 更新相关命名空间引用
- 修改FileStorage类的XML注释文档
This commit is contained in:
GeWuYou 2026-01-19 19:08:59 +08:00
parent a30e576c03
commit c223fbcb5c
5 changed files with 24 additions and 5 deletions

View File

@ -52,7 +52,8 @@ public class GFrameworkConstantsTests
// 如果常量不存在或不是公共的,编译会失败或抛出异常
Assert.DoesNotThrow(() =>
{
var name = GFrameworkConstants.FrameworkName;
const string name = GFrameworkConstants.FrameworkName;
Console.WriteLine(name);
});
}

View File

@ -0,0 +1,9 @@
using GFramework.Core.Abstractions.storage;
namespace GFramework.Game.Abstractions.storage;
/// <summary>
/// 文件存储接口,定义了文件存储操作的契约
/// 继承自IStorage接口提供专门针对文件的存储功能
/// </summary>
public interface IFileStorage : IStorage;

View File

@ -0,0 +1,8 @@
using GFramework.Core.Abstractions.storage;
namespace GFramework.Game.Abstractions.storage;
/// <summary>
/// 表示作用域存储接口,继承自基础存储接口
/// </summary>
public interface IScopedStorage : IStorage;

View File

@ -1,14 +1,14 @@
using System.Collections.Concurrent;
using System.Text;
using GFramework.Core.Abstractions.storage;
using GFramework.Game.Abstractions.serializer;
using GFramework.Game.Abstractions.storage;
namespace GFramework.Game.storage;
/// <summary>
/// 基于文件系统的存储实现实现了IStorage接口支持按key细粒度锁保证线程安全
/// 基于文件系统的存储实现实现了IFileStorage接口支持按key细粒度锁保证线程安全
/// </summary>
public sealed class FileStorage : IStorage
public sealed class FileStorage : IFileStorage
{
private readonly string _extension;

View File

@ -1,4 +1,5 @@
using GFramework.Core.Abstractions.storage;
using GFramework.Game.Abstractions.storage;
namespace GFramework.Game.storage;
@ -7,7 +8,7 @@ namespace GFramework.Game.storage;
/// </summary>
/// <param name="inner">内部的实际存储实现</param>
/// <param name="prefix">用于所有键的前缀字符串</param>
public sealed class ScopedStorage(IStorage inner, string prefix) : IStorage
public sealed class ScopedStorage(IStorage inner, string prefix) : IScopedStorage
{
/// <summary>
/// 检查指定键是否存在