0
0
mirror of https://github.com/sp-tarkov/loot-dump-processor.git synced 2025-02-13 09:50:44 -05:00
CWX 39ac387aae
Per map process (#1)
* Seperate Tasks into their own methods, Add method to add map name to file name

* Formatting and added a few comments

* Add Clear method to collectors

* Change to local var, so data isnt stored longer than needed

* add Clear method to Storages

* Add changes for Per Map Processing and file i forgot to commit last time

* Update config to have mapNames in it, removed unused yaml file

* update comment

* changed to not throw so Filemode still can be used
2024-12-31 09:12:48 +00:00

58 lines
1.2 KiB
C#

namespace LootDumpProcessor.Storage.Implementations.Memory;
public class MemoryDataStorage : IDataStorage
{
private static readonly Dictionary<string, object> CachedObjects = new();
private static readonly object _cacheObjectLock = new();
public void Setup()
{
}
public void Store<T>(T t) where T : IKeyable
{
lock (_cacheObjectLock)
{
CachedObjects.Add(GetLookupKey(t.GetKey()), t);
}
}
public bool Exists(IKey t)
{
lock (_cacheObjectLock)
{
return CachedObjects.ContainsKey(GetLookupKey(t));
}
}
public T? GetItem<T>(IKey key) where T : IKeyable
{
lock (_cacheObjectLock)
{
if (CachedObjects.TryGetValue(GetLookupKey(key), out var value))
{
return (T)value;
}
}
return default;
}
public List<T> GetAll<T>()
{
throw new NotImplementedException();
}
private string GetLookupKey(IKey key)
{
return string.Join("-", key.GetLookupIndex());
}
public void Clear()
{
lock (_cacheObjectLock)
{
CachedObjects.Clear();
}
}
}