src/DotNetCommon.Core/Cache/Impl/CacheEntry.cs
(开头部分) 9KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
//using Microsoft.Extensions.Primitives;
//using System;
//using System.Collections.Generic;
//using System.Runtime.CompilerServices;
//using System.Text;
//using System.Threading;
//using System.Threading.Tasks;
//
//namespace DotNetCommon.Cache.Impl
//{
// internal sealed partial class CacheEntry : ICacheEntry
// {
// private static readonly Action<object> ExpirationCallback = ExpirationTokensExpired;
//
// private readonly MemoryCache _cache;
//
// private CacheEntryTokens _tokens; // might be null if user is not using the tokens or callbacks
// private TimeSpan? _absoluteExpirationRelativeToNow;
// private TimeSpan? _slidingExpiration;
// private long? _size;
// private CacheEntry _previous; // this field is not null only before the entry is added to the cache
// private object _value;
// private CacheEntryState _state;
//
// internal CacheEntry(object key, MemoryCache memoryCache)
// {
// Key = key ?? throw new ArgumentNullException(nameof(key));
// _cache = memoryCache ?? throw new ArgumentNullException(nameof(memoryCache));
// _previous = CacheEntryHelper.EnterScope(this);
// _state = new CacheEntryState(CacheItemPriority.Normal);
// }
//
// /// <summary>
// /// Gets or sets an absolute expiration date for the cache entry.
// /// </summary>
// public DateTimeOffset? AbsoluteExpiration { get; set; }
//
// /// <summary>
// /// Gets or sets an absolute expiration time, relative to now.
// /// </summary>
// public TimeSpan? AbsoluteExpirationRelativeToNow
// {
// get => _absoluteExpirationRelativeToNow;
// set
// {
// // this method does not set AbsoluteExpiration as it would require calling Clock.UtcNow twice:
// // once here and once in MemoryCache.SetEntry
//
// if (value <= TimeSpan.Zero)
// {
// throw new ArgumentOutOfRangeException(
// nameof(AbsoluteExpirationRelativeToNow),
// value,
// "The relative expiration value must be positive.");
// }
//
// _absoluteExpirationRelativeToNow = value;
// }
// }
//
后面还有 191 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
