Commit 36bf7d7e authored by Liang Ding's avatar Liang Ding

🎨 清理冗余代码

parent ae78e3e1
/*
* Solo - A small and beautiful blogging system written in Java.
* Copyright (c) 2010-present, b3log.org
*
* Solo is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
package org.b3log.solo.cache;
import org.b3log.latke.ioc.Singleton;
import org.b3log.solo.model.Option;
import org.json.JSONObject;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* Statistic cache.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.1, Sep 25, 2018
* @since 2.4.0
*/
@Singleton
public class StatisticCache {
/**
* Statistic cache.
*/
private final Map<String, JSONObject> cache = new ConcurrentHashMap<>();
/**
* Get the statistic.
*
* @return statistic
*/
public JSONObject getStatistic() {
return cache.get(Option.CATEGORY_C_STATISTIC);
}
/**
* Adds or updates the specified statistic.
*
* @param statistic the specified statistic
*/
public void putStatistic(final JSONObject statistic) {
cache.put(Option.CATEGORY_C_STATISTIC, statistic);
}
/**
* Clears all cached data.
*/
public void clear() {
cache.clear();
}
}
...@@ -25,7 +25,6 @@ import org.b3log.latke.service.ServiceException; ...@@ -25,7 +25,6 @@ import org.b3log.latke.service.ServiceException;
import org.b3log.latke.service.annotation.Service; import org.b3log.latke.service.annotation.Service;
import org.b3log.latke.util.Requests; import org.b3log.latke.util.Requests;
import org.b3log.latke.util.URLs; import org.b3log.latke.util.URLs;
import org.b3log.solo.cache.StatisticCache;
import org.b3log.solo.repository.ArticleRepository; import org.b3log.solo.repository.ArticleRepository;
import org.b3log.solo.repository.OptionRepository; import org.b3log.solo.repository.OptionRepository;
import org.b3log.solo.util.Solos; import org.b3log.solo.util.Solos;
...@@ -41,7 +40,7 @@ import java.util.concurrent.ConcurrentHashMap; ...@@ -41,7 +40,7 @@ import java.util.concurrent.ConcurrentHashMap;
* Statistic management service. * Statistic management service.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 2.0.1.5, Jan 8, 2020 * @version 2.0.1.6, Apr 14, 2020
* @since 0.5.0 * @since 0.5.0
*/ */
@Service @Service
...@@ -88,12 +87,6 @@ public class StatisticMgmtService { ...@@ -88,12 +87,6 @@ public class StatisticMgmtService {
@Inject @Inject
private ArticleRepository articleRepository; private ArticleRepository articleRepository;
/**
* Statistic cache.
*/
@Inject
private StatisticCache statisticCache;
/** /**
* Removes the expired online visitor. * Removes the expired online visitor.
*/ */
...@@ -267,6 +260,5 @@ public class StatisticMgmtService { ...@@ -267,6 +260,5 @@ public class StatisticMgmtService {
*/ */
private void updateStatistic(final String id, final JSONObject statistic) throws RepositoryException { private void updateStatistic(final String id, final JSONObject statistic) throws RepositoryException {
optionRepository.update(id, statistic); optionRepository.update(id, statistic);
statisticCache.clear();
} }
} }
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