Class InMemoryOtpRepository
- Namespace
- SEBT.Portal.Infrastructure.Repositories
- Assembly
- SEBT.Portal.Infrastructure.dll
An in-memory implementation of IOtpRepository that uses Microsoft.Extensions.Caching.Memory.IMemoryCache for storing OTP codes.
public class InMemoryOtpRepository : IOtpRepository
- Inheritance
-
objectInMemoryOtpRepository
- Implements
Remarks
This implementation is suitable for single-instance applications. For distributed scenarios, consider using a distributed cache implementation instead.
Constructors
InMemoryOtpRepository(IMemoryCache)
An in-memory implementation of IOtpRepository that uses Microsoft.Extensions.Caching.Memory.IMemoryCache for storing OTP codes.
public InMemoryOtpRepository(IMemoryCache memoryCache)
Parameters
memoryCacheIMemoryCacheThe memory cache instance used to store and retrieve OTP codes.
Remarks
This implementation is suitable for single-instance applications. For distributed scenarios, consider using a distributed cache implementation instead.
Methods
DeleteOtpCodeByEmailAsync(string)
Deletes the OTP code associated with the specified email.
public Task DeleteOtpCodeByEmailAsync(string email)
Parameters
emailstringThe email address associated with the OTP code to delete.
Returns
- Task
A task representing the asynchronous operation.
GetOtpCodeByEmailAsync(string)
Retrieves the OTP code associated with the specified email.
public Task<OtpCode?> GetOtpCodeByEmailAsync(string email)
Parameters
emailstringThe email address associated with the OTP code.
Returns
- Task<OtpCode>
A task that represents the asynchronous operation. The task result contains the OTP code if found; otherwise,
null.
SaveOtpCodeAsync(OtpCode)
Saves the provided OTP code to the repository.
public Task SaveOtpCodeAsync(OtpCode newOtpCode)
Parameters
newOtpCodeOtpCode
Returns
- Task
A task representing the asynchronous operation.