diff --git a/src/DataValue.cs b/src/DataValue.cs index 131abff..9c73a4f 100644 --- a/src/DataValue.cs +++ b/src/DataValue.cs @@ -92,8 +92,11 @@ namespace OpenSim.Modules.DataValue if (m_storageTyp == "MYSQL") m_storage = new MySQL(m_scene, m_config); - if(m_storage == null) - m_storage = new FileSystem(m_scene, m_config); + if (m_storageTyp == "MEMORY") + m_storage = new Memory(); + + if (m_storage == null) + m_storage = new Memory(); m_scriptModule = m_scene.RequestModuleInterface(); if (m_scriptModule != null) diff --git a/src/Storage/Memory.cs b/src/Storage/Memory.cs new file mode 100644 index 0000000..4b3c052 --- /dev/null +++ b/src/Storage/Memory.cs @@ -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 m_storage = new List(); + + 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; + } + } +}