초기커밋
This commit is contained in:
39
ServerCore/Redis/RedisTransaction.cs
Normal file
39
ServerCore/Redis/RedisTransaction.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using StackExchange.Redis;
|
||||
|
||||
|
||||
namespace ServerCore;
|
||||
|
||||
public class RedisTransaction : IDisposable
|
||||
{
|
||||
private readonly ITransaction m_transaction;
|
||||
private bool m_committed = false;
|
||||
|
||||
public RedisTransaction(IDatabase db)
|
||||
{
|
||||
m_transaction = db.CreateTransaction();
|
||||
}
|
||||
|
||||
public async Task commitAsync()
|
||||
{
|
||||
m_committed = await m_transaction.ExecuteAsync();
|
||||
}
|
||||
|
||||
// Dispose에서 트랜잭션 해제 처리
|
||||
public void Dispose()
|
||||
{
|
||||
if (false == m_committed)
|
||||
{
|
||||
// 트랜잭션을 취소
|
||||
m_transaction.Execute();
|
||||
}
|
||||
}
|
||||
|
||||
public ITransaction getTransaction() => m_transaction;
|
||||
}
|
||||
Reference in New Issue
Block a user