server-master/srcs/PhoenixLib.DAL.Redis/Locks/IExpirableLockService.cs
2026-02-10 18:21:30 +01:00

46 lines
No EOL
1.6 KiB
C#

using System;
using System.Threading.Tasks;
namespace PhoenixLib.DAL.Redis.Locks
{
public interface IExpirableLockService
{
/// <summary>
/// Sets a key without increment with a defined expiration date
/// </summary>
/// <param name="key"></param>
/// <param name="expirationDate"></param>
/// <returns>true if the key already exist</returns>
Task<bool> TryAddTemporaryLockAsync(string key, DateTime expirationDate);
/// <summary>
/// Sets an incremental key with a defined maxValue, expires on the specified expirationDate
/// </summary>
/// <param name="key"></param>
/// <param name="maxValue"></param>
/// <param name="expirationDate"></param>
/// <returns></returns>
Task<(bool, int newValue)> TryIncrementTemporaryLockCounter(string key, int maxValue, DateTime expirationDate);
/// <summary>
/// Try getting the current value of the counter
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
Task<(bool, int newValue)> TryGetTemporaryCounterValue(string key);
/// <summary>
/// Removes a key if exists
/// </summary>
/// <param name="key"></param>
/// <returns>true if the key exists and got removed</returns>
Task<bool> TryRemoveTemporaryLock(string key);
/// <summary>
/// Checks if a key exists
/// </summary>
/// <param name="key"></param>
/// <returns>true if the key exists</returns>
Task<bool> ExistsTemporaryLock(string key);
}
}