Various updates.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace Harmonia.Core.Caching;
|
||||
|
||||
@@ -27,10 +28,16 @@ public abstract class MemoryCache<TKey, TValue> : Cache<TKey, TValue> where TKey
|
||||
|
||||
var cacheEntryOptions = new MemoryCacheEntryOptions()
|
||||
.SetSize(entrySize)
|
||||
.SetSlidingExpiration(SlidingExpiration);
|
||||
.SetSlidingExpiration(SlidingExpiration)
|
||||
.RegisterPostEvictionCallback(PostEvictionCallback);
|
||||
|
||||
_memoryCache.Set(key, entry, cacheEntryOptions);
|
||||
}
|
||||
|
||||
protected virtual void PostEvictionCallback(object? cacheKey, object? cacheValue, EvictionReason evictionReason, object? state)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected abstract long GetEntrySize(TValue entry);
|
||||
}
|
||||
Reference in New Issue
Block a user