From dd766b8700e60b6ec54c61e829be8601be472770 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 12 Apr 2019 23:23:18 -0400 Subject: [PATCH] config service: remove writing to sql --- .../http/service/config/ConfigService.java | 50 ------------------- 1 file changed, 50 deletions(-) diff --git a/http-service/src/main/java/net/runelite/http/service/config/ConfigService.java b/http-service/src/main/java/net/runelite/http/service/config/ConfigService.java index de665fc44f..27653d411b 100644 --- a/http-service/src/main/java/net/runelite/http/service/config/ConfigService.java +++ b/http-service/src/main/java/net/runelite/http/service/config/ConfigService.java @@ -46,54 +46,21 @@ import net.runelite.http.api.config.ConfigEntry; import net.runelite.http.api.config.Configuration; import org.bson.Document; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Service; -import org.sql2o.Connection; -import org.sql2o.Sql2o; -import org.sql2o.Sql2oException; @Service @Slf4j public class ConfigService { - private static final String CREATE_CONFIG = "CREATE TABLE IF NOT EXISTS `config` (\n" - + " `user` int(11) NOT NULL,\n" - + " `key` tinytext NOT NULL,\n" - + " `value` text NOT NULL,\n" - + " UNIQUE KEY `user_key` (`user`,`key`(64))\n" - + ") ENGINE=InnoDB;"; - - private static final String CONFIG_FK = "ALTER TABLE `config`\n" - + " ADD CONSTRAINT `user_fk` FOREIGN KEY (`user`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;"; - - private final Sql2o sql2o; private final Gson GSON = RuneLiteAPI.GSON; private final MongoCollection mongoCollection; @Autowired public ConfigService( - @Qualifier("Runelite SQL2O") Sql2o sql2o, MongoClient mongoClient ) { - this.sql2o = sql2o; - - try (Connection con = sql2o.open()) - { - con.createQuery(CREATE_CONFIG) - .executeUpdate(); - - try - { - con.createQuery(CONFIG_FK) - .executeUpdate(); - } - catch (Sql2oException ex) - { - // Ignore, happens when index already exists - } - } MongoDatabase database = mongoClient.getDatabase("config"); MongoCollection collection = database.getCollection("config"); @@ -160,15 +127,6 @@ public class ConfigService @Nullable String value ) { - try (Connection con = sql2o.open()) - { - con.createQuery("insert into config (user, `key`, value) values (:user, :key, :value) on duplicate key update `key` = :key, value = :value") - .addParameter("user", userId) - .addParameter("key", key) - .addParameter("value", value != null ? value : "") - .executeUpdate(); - } - if (key.startsWith("$") || key.startsWith("_")) { return; @@ -190,14 +148,6 @@ public class ConfigService String key ) { - try (Connection con = sql2o.open()) - { - con.createQuery("delete from config where user = :user and `key` = :key") - .addParameter("user", userId) - .addParameter("key", key) - .executeUpdate(); - } - if (key.startsWith("$") || key.startsWith("_")) { return;