public void RemoveConfigurationObject(string name) { var key = PrefixConstants.GetUniqueConfigurationObjectKey(name); byte[] bytesKey = Encoding.UTF8.GetBytes(key); try { _database.Delete(bytesKey); } catch (Exception e) { _logger.Error(e, $"Failed to write configuration object {name}"); } }
public void WriteConfigurationObject(ConfigurationEntity obj) { var key = PrefixConstants.GetUniqueConfigurationObjectKey(obj.Name); byte[] bytesKey = Encoding.UTF8.GetBytes(key); string stringValue = JsonSerializer.Serialize(obj); byte[] bytesValue = Encoding.UTF8.GetBytes(stringValue); try { _database.Put(bytesKey, bytesValue); } catch (Exception e) { _logger.Error(e, $"Failed to write configuration object {obj.Name}"); } }
public ConfigurationEntity ReadConfigurationObject(string name) { var key = PrefixConstants.GetUniqueConfigurationObjectKey(name); byte[] bytesKey = Encoding.UTF8.GetBytes(key); try { bool isRead = _database.TryRead(bytesKey, out byte[] value); if (!isRead) { throw new ServerDatabaseException("Failed to read configuration object info"); } return(JsonSerializer.Deserialize <ConfigurationEntity>(Encoding.UTF8.GetString(value))); } catch (Exception e) { _logger.Error(e, $"Failed to read configuration object {name}"); } return(null); }