add memory storage

master
Christopher 2020-07-08 02:05:14 +02:00
parent 46775cf1c3
commit 1f12905f14
2 changed files with 70 additions and 2 deletions

View File

@ -92,8 +92,11 @@ namespace OpenSim.Modules.DataValue
if (m_storageTyp == "MYSQL") if (m_storageTyp == "MYSQL")
m_storage = new MySQL(m_scene, m_config); m_storage = new MySQL(m_scene, m_config);
if(m_storage == null) if (m_storageTyp == "MEMORY")
m_storage = new FileSystem(m_scene, m_config); m_storage = new Memory();
if (m_storage == null)
m_storage = new Memory();
m_scriptModule = m_scene.RequestModuleInterface<IScriptModuleComms>(); m_scriptModule = m_scene.RequestModuleInterface<IScriptModuleComms>();
if (m_scriptModule != null) if (m_scriptModule != null)

65
src/Storage/Memory.cs Normal file
View File

@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OpenSim.Modules.DataValue.Storage
{
class Memory : iStorage
{
List<MemoryStorageObjekt> m_storage = new List<MemoryStorageObjekt>();
public bool check(string storageID, string key)
{
MemoryStorageObjekt _storageObjekt = m_storage.Find(X => X.StorageID == storageID && X.StorageKey == key);
if (_storageObjekt != null)
return true;
return false;
}
public string get(string storageID, string key)
{
MemoryStorageObjekt _storageObjekt = m_storage.Find(X => X.StorageID == storageID && X.StorageKey == key);
if (_storageObjekt != null)
return _storageObjekt.StorageData;
return null;
}
public void remove(string storageID, string key)
{
MemoryStorageObjekt _storageObjekt = m_storage.Find(X => X.StorageID == storageID && X.StorageKey == key);
if (_storageObjekt != null)
m_storage.Remove(_storageObjekt);
}
public void save(string storageID, string key, string data)
{
MemoryStorageObjekt _storageObjekt = m_storage.Find(X => X.StorageID == storageID && X.StorageKey == key);
if (_storageObjekt != null)
_storageObjekt.StorageData = data;
m_storage.Add(new MemoryStorageObjekt(storageID, key, data));
}
}
class MemoryStorageObjekt
{
public String StorageID = null;
public String StorageKey = null;
public String StorageData = null;
public MemoryStorageObjekt(String id, String key, String data)
{
StorageID = id;
StorageKey = key;
StorageData = data;
}
}
}