/// <summary> /// Initializes a new instance. /// </summary> /// <param name="key"></param> /// <param name="data"></param> /// <param name="handle"></param> public KsInMemoryStoreEntry(KsInMemoryStore <TKey> store, TKey key, KsInMemoryStoreData <TKey> data, AsyncLock.AsyncLockHandle handle) { this.store = store ?? throw new ArgumentNullException(nameof(store)); this.key = key; this.data = data ?? throw new ArgumentNullException(nameof(data)); this.handle = handle; }
/// <summary> /// Runs a task that times out when the freeze expires. /// </summary> /// <param name="store"></param> /// <param name="key"></param> /// <param name="timeout"></param> /// <param name="cancellationToken"></param> /// <returns></returns> static async Task FreezeTimeoutTask(KsInMemoryStore <TKey> store, TKey key, TimeSpan timeout, CancellationToken cancellationToken) { // wait the appropriate timeout await Task.Delay(timeout, cancellationToken); // erase the freeze data await using var entry = (KsInMemoryStoreEntry <TKey>) await store.OpenAsync(key, cancellationToken); entry.data.FreezeLockTimer = null; entry.data.FreezeLockCancel = null; entry.data.FreezeLockToken = null; }