diff --git a/CacheDrive/Models/ObjectItem.cs b/CacheDrive/Models/CacheableItem.cs similarity index 80% rename from CacheDrive/Models/ObjectItem.cs rename to CacheDrive/Models/CacheableItem.cs index 0ea22f3..abebe30 100644 --- a/CacheDrive/Models/ObjectItem.cs +++ b/CacheDrive/Models/CacheableItem.cs @@ -2,7 +2,7 @@ namespace CacheDrive.Models; -public class ObjectItem : ICacheable +public class CacheableItem : ICacheable { [JsonPropertyName("key")] public string Key { get; set; } @@ -17,6 +17,6 @@ public string CacheKey public static string GetCacheKey(string key) => $"{typeof(T).Name.ToLower()}@{key}"; - public static ObjectItem Create(string key, T value) + public static CacheableItem Create(string key, T value) => new() { Key = key, Value = value }; } \ No newline at end of file diff --git a/CacheDrive/Services/MemoryCacheService.cs b/CacheDrive/Services/MemoryCacheService.cs index 312e216..94715f6 100644 --- a/CacheDrive/Services/MemoryCacheService.cs +++ b/CacheDrive/Services/MemoryCacheService.cs @@ -39,7 +39,7 @@ public bool HasItem(string key) public bool TryGetValue(string key, out T value) { - if (TryGetCacheableValue(key, out ObjectItem result)) + if (TryGetCacheableValue(key, out CacheableItem result)) { if (result == null) { @@ -81,7 +81,7 @@ private bool TryGetCacheableValue(string key, out T value) where T : ICacheab public async Task GetAsync(string key) { - ObjectItem cachedItem = await GetCacheableAsync>(key); + CacheableItem cachedItem = await GetCacheableAsync>(key); if (cachedItem is null) { @@ -128,7 +128,7 @@ public void Set(T item, int expirySeconds = 0) where T : ICacheable public Task SetAsync(string key, T value, int expirySeconds = 0) { - return SetAsync(ObjectItem.Create(key, value), expirySeconds); + return SetAsync(CacheableItem.Create(key, value), expirySeconds); } public Task SetAsync(T item, int expirySeconds = 0) where T : ICacheable