Commit 24432b8a authored by Liang Ding's avatar Liang Ding

#12509 升级子程序

parent 03d62008
...@@ -30,7 +30,7 @@ import org.json.JSONObject; ...@@ -30,7 +30,7 @@ import org.json.JSONObject;
* Article cache. * Article cache.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.0, Aug 30, 2017 * @version 1.2.0.0, Sep 16, 2018
* @since 2.3.0 * @since 2.3.0
*/ */
@Named @Named
...@@ -95,4 +95,12 @@ public class ArticleCache { ...@@ -95,4 +95,12 @@ public class ArticleCache {
public void removeArticle(final String id) { public void removeArticle(final String id) {
idCache.remove(id); idCache.remove(id);
} }
/**
* Clears all cached articles.
*/
public void clear() {
idCache.removeAll();
permalinkCache.removeAll();
}
} }
\ No newline at end of file
...@@ -30,7 +30,7 @@ import org.json.JSONObject; ...@@ -30,7 +30,7 @@ import org.json.JSONObject;
* Comment cache. * Comment cache.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.0, Jul 16, 2017 * @version 1.1.0.0, Sep 16, 2018
* @since 2.3.0 * @since 2.3.0
*/ */
@Named @Named
...@@ -74,4 +74,11 @@ public class CommentCache { ...@@ -74,4 +74,11 @@ public class CommentCache {
public void removeComment(final String id) { public void removeComment(final String id) {
cache.remove(id); cache.remove(id);
} }
/**
* Clears all cached comments.
*/
public void clear() {
cache.removeAll();
}
} }
...@@ -27,11 +27,14 @@ import org.b3log.latke.mail.MailServiceFactory; ...@@ -27,11 +27,14 @@ import org.b3log.latke.mail.MailServiceFactory;
import org.b3log.latke.model.User; import org.b3log.latke.model.User;
import org.b3log.latke.repository.Query; import org.b3log.latke.repository.Query;
import org.b3log.latke.repository.Transaction; import org.b3log.latke.repository.Transaction;
import org.b3log.latke.repository.jdbc.JdbcRepository;
import org.b3log.latke.repository.jdbc.util.Connections; import org.b3log.latke.repository.jdbc.util.Connections;
import org.b3log.latke.service.LangPropsService; import org.b3log.latke.service.LangPropsService;
import org.b3log.latke.service.ServiceException; import org.b3log.latke.service.ServiceException;
import org.b3log.latke.service.annotation.Service; import org.b3log.latke.service.annotation.Service;
import org.b3log.solo.SoloServletListener; import org.b3log.solo.SoloServletListener;
import org.b3log.solo.cache.ArticleCache;
import org.b3log.solo.cache.CommentCache;
import org.b3log.solo.model.Article; import org.b3log.solo.model.Article;
import org.b3log.solo.model.Comment; import org.b3log.solo.model.Comment;
import org.b3log.solo.model.Option; import org.b3log.solo.model.Option;
...@@ -130,6 +133,18 @@ public class UpgradeService { ...@@ -130,6 +133,18 @@ public class UpgradeService {
@Inject @Inject
private LangPropsService langPropsService; private LangPropsService langPropsService;
/**
* Article cache.
*/
@Inject
private ArticleCache articleCache;
/**
* Comment cache.
*/
@Inject
private CommentCache commentCache;
/** /**
* Upgrades if need. * Upgrades if need.
*/ */
...@@ -178,8 +193,12 @@ public class UpgradeService { ...@@ -178,8 +193,12 @@ public class UpgradeService {
alterTables(); alterTables();
upgradeArticles(); upgradeArticles();
upgradeComments(); upgradeComments();
JdbcRepository.dispose(); // avoid to metadata lock
dropColumns(); dropColumns();
articleCache.clear();
commentCache.clear();
final Transaction transaction = optionRepository.beginTransaction(); final Transaction transaction = optionRepository.beginTransaction();
final JSONObject versionOpt = optionRepository.get(Option.ID_C_VERSION); final JSONObject versionOpt = optionRepository.get(Option.ID_C_VERSION);
versionOpt.put(Option.OPTION_VALUE, TO_VER); versionOpt.put(Option.OPTION_VALUE, TO_VER);
...@@ -218,9 +237,9 @@ public class UpgradeService { ...@@ -218,9 +237,9 @@ public class UpgradeService {
final Statement statement = connection.createStatement(); final Statement statement = connection.createStatement();
final String tablePrefix = Latkes.getLocalProperty("jdbc.tablePrefix") + "_"; final String tablePrefix = Latkes.getLocalProperty("jdbc.tablePrefix") + "_";
statement.execute("ALTER TABLE `" + tablePrefix + "article` DROP COLUMN `articleCreateDate`"); statement.executeUpdate("ALTER TABLE `" + tablePrefix + "article` DROP COLUMN `articleCreateDate`");
statement.execute("ALTER TABLE `" + tablePrefix + "article` DROP COLUMN `articleUpdateDate`"); statement.executeUpdate("ALTER TABLE `" + tablePrefix + "article` DROP COLUMN `articleUpdateDate`");
statement.execute("ALTER TABLE `" + tablePrefix + "comment` DROP COLUMN `commentDate`"); statement.executeUpdate("ALTER TABLE `" + tablePrefix + "comment` DROP COLUMN `commentDate`");
statement.close(); statement.close();
connection.commit(); connection.commit();
connection.close(); connection.close();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment