33 lines
942 B
C#
33 lines
942 B
C#
using System.Collections.Concurrent;
|
|
|
|
namespace ArmaRAMDb
|
|
{
|
|
internal class KeyValueStore
|
|
{
|
|
private static readonly ConcurrentDictionary<string, string> _keyValues = RAMDb._keyValues;
|
|
|
|
public static string GetValue(string key)
|
|
{
|
|
string value = _keyValues.TryGetValue(key, out string data) ? data : string.Empty;
|
|
|
|
Main.Log($"GetValue: {key} - Value: {value}", "debug");
|
|
return value;
|
|
}
|
|
|
|
public static bool DeleteValue(string key)
|
|
{
|
|
var result = _keyValues.TryRemove(key, out _);
|
|
|
|
Main.Log($"DeleteValue: {key} - Success: {result}", "debug");
|
|
return result;
|
|
}
|
|
|
|
public static bool SetValue(string key, string value)
|
|
{
|
|
_keyValues.AddOrUpdate(key, value, (_, _) => value);
|
|
|
|
Main.Log($"SetValue: {key} - Value: {value}", "debug");
|
|
return true;
|
|
}
|
|
}
|
|
} |