빌드 경고 해결 및 데이터 검증 진행중.

This commit is contained in:
Lectom C Han
2026-01-08 18:09:21 +09:00
parent 2d84a26053
commit 7b93467c6e
6 changed files with 206 additions and 81 deletions

View File

@@ -9,10 +9,10 @@ namespace SchemaEditor.Services;
public class GarnetClientService : IStorageWrapper, IDisposable
{
private ConnectionMultiplexer _redis;
private IDatabase _db;
private ConnectionMultiplexer? _redis;
private IDatabase? _db;
public bool IsConnected => _redis != null && _redis.IsConnected;
public bool IsConnected => _redis?.IsConnected == true;
public void Connect(string connectionString = "localhost:3187")
{
@@ -26,7 +26,7 @@ public class GarnetClientService : IStorageWrapper, IDisposable
public async Task SetAsync(string key, string value)
{
if (_db == null) Connect();
await _db.StringSetAsync(key, value);
if (_db != null) await _db.StringSetAsync(key, value);
}
public async Task SetAsync(string key, string value, int row, int col)
@@ -35,19 +35,21 @@ public class GarnetClientService : IStorageWrapper, IDisposable
// Traceability metadata (row, col) could be stored in a hash or side key if needed.
// For now, we just proceed with standard storage.
if (_db == null) Connect();
await _db.StringSetAsync(key, value);
if (_db != null) await _db.StringSetAsync(key, value);
}
public async Task IncrementAsync(string key, double value)
{
if (_db == null) Connect();
await _db.StringIncrementAsync(key, value);
if (_db != null) await _db.StringIncrementAsync(key, value);
}
// For Data Explorer
public async Task<List<string>> SearchKeysAsync(string pattern)
{
if (_db == null) Connect();
if (_redis == null || _db == null) return await Task.FromResult(new List<string>());
var server = _redis.GetServer(_redis.GetEndPoints().First());
// Use Keys for simplicity in Schema Editor (low traffic)
// In high production, use SCAN
@@ -58,7 +60,9 @@ public class GarnetClientService : IStorageWrapper, IDisposable
public async Task<string> GetValueAsync(string key)
{
if (_db == null) Connect();
return await _db.StringGetAsync(key);
if (_db == null) return string.Empty;
var val = await _db.StringGetAsync(key);
return val.HasValue ? val.ToString() : string.Empty;
}
public void Dispose()

View File

@@ -11,18 +11,18 @@ public class GarnetHost : IHostedService, IDisposable
private GarnetServer? _server;
public Task StartAsync(CancellationToken cancellationToken)
{
try
{
var serverArgs = new string[] { "--port", "3187" }; // Changed to 3187
_server = new GarnetServer(serverArgs);
_server.Start();
Console.WriteLine("[GarnetHost] Server started on port 3278");
}
catch (Exception ex)
{
Console.WriteLine($"[GarnetHost] Failed to start: {ex.Message}");
}
try
{
var serverArgs = new string[] { "--port", "3187" }; // Changed to 3187
_server = new GarnetServer(serverArgs);
_server.Start();
Console.WriteLine("[GarnetHost] Server started on port 3187");
}
catch (Exception ex)
{
Console.WriteLine($"[GarnetHost] Failed to start: {ex.Message}");
}
return Task.CompletedTask;
}