Update ArcCacheTable.cs

This commit is contained in:
ALEXTANG
2023-04-10 17:38:24 +08:00
parent 3809da762c
commit 48724e4bde

View File

@@ -2,7 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
namespace TEngine.ArcCache namespace TEngine
{ {
/// <summary> /// <summary>
/// Adaptive Replacement Cache缓存表。 /// Adaptive Replacement Cache缓存表。
@@ -70,7 +70,7 @@ namespace TEngine.ArcCache
/// <param name="value">值。</param> /// <param name="value">值。</param>
public void PutCache(TKey key, TValue value) public void PutCache(TKey key, TValue value)
{ {
QueueNode<TKey, TValue> queueNode = CacheStorageMap[key]; CacheStorageMap.TryGetValue(key, out QueueNode<TKey, TValue> queueNode);
if (queueNode == null) if (queueNode == null)
{ {
@@ -100,7 +100,7 @@ namespace TEngine.ArcCache
/// <returns>TValue from cache if exists or null。</returns> /// <returns>TValue from cache if exists or null。</returns>
public TValue GetCache(TKey key) public TValue GetCache(TKey key)
{ {
QueueNode<TKey, TValue> queueNode = CacheStorageMap[key]; CacheStorageMap.TryGetValue(key, out QueueNode<TKey, TValue> queueNode);
if (queueNode == null) if (queueNode == null)
{ {
@@ -247,7 +247,7 @@ namespace TEngine.ArcCache
TValue value = queueNodeToBeRemoved.Get(); TValue value = queueNodeToBeRemoved.Get();
try try
{ {
//Dispose(value); OnRemoveCallback?.Invoke(value);
} }
catch (System.Exception e) catch (System.Exception e)
{ {
@@ -264,7 +264,7 @@ namespace TEngine.ArcCache
if (keys == "") if (keys == "")
keys += key; keys += key;
else else
keys += ", " + key; keys += " | " + key;
} }
Debug.Log("All Existing Keys in Cache are : " + keys); Debug.Log("All Existing Keys in Cache are : " + keys);