Merge branch 'master' into docker_package

This commit is contained in:
wangliwen 2022-07-06 11:51:26 +08:00
commit e606ec0499
3 changed files with 24 additions and 5 deletions

View File

@ -11,6 +11,8 @@ import io.renren.modules.category.service.CategoryService;
import io.renren.modules.resource.dao.AttrDao;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -26,7 +28,9 @@ import java.util.concurrent.Executors;
@Service
public class CategoryServiceImpl extends CrudServiceImpl<CategoryDao, Category, CategoryDTO> implements CategoryService {
private static Integer cpuNUm = Runtime.getRuntime().availableProcessors();
private static final ExecutorService executor = Executors.newFixedThreadPool(cpuNUm);
private static final ExecutorService executor = Executors.newCachedThreadPool();
private static final String getCategoryTreeKey = "getCategoryTree";
@Autowired
private CategoryDao categoryDao;
@ -39,6 +43,7 @@ public class CategoryServiceImpl extends CrudServiceImpl<CategoryDao, Category,
}
@Override
@Cacheable(value = getCategoryTreeKey, key = "'getCategoryTree'")
public List<CategoryDTO> getCategoryTree() {
List<Category> topCategory = categoryDao.selectByParentId(null);
List<CategoryDTO> list = new CopyOnWriteArrayList<>();
@ -82,6 +87,7 @@ public class CategoryServiceImpl extends CrudServiceImpl<CategoryDao, Category,
@Override
@Transactional
@CacheEvict(key = getCategoryTreeKey, allEntries = true)
public void deleteByIds(JSONObject jsonObject) {
JSONArray jsonArray = jsonObject.getJSONArray("ids");
//TODO删除为一级分类时删除模板保存的文件夹
@ -125,6 +131,7 @@ public class CategoryServiceImpl extends CrudServiceImpl<CategoryDao, Category,
@Override
@Transactional
@CacheEvict(key = getCategoryTreeKey, allEntries = true)
public void update(CategoryDTO categoryDTO) {
super.update(categoryDTO);
String oldName = categoryDao.selectById(categoryDTO.getId()).getName();

View File

@ -26,10 +26,13 @@ spring:
# url: jdbc:postgresql://192.168.10.10:5432/postgres
# username: postgres
# password: 123456
initial-size: 10
max-active: 100
min-idle: 10
max-wait: 10
initial-size: 50
max-active: 1000
min-idle: 100
max-wait: 100
removeAbandoned: true
removeAbandonedTimeout: 300
logAbandoned: false
pool-prepared-statements: true
max-pool-prepared-statement-per-connection-size: 20
time-between-eviction-runs-millis: 60000

View File

@ -66,4 +66,13 @@
overflowToDisk="true"
memoryStoreEvictionPolicy="LRU"/>
<!-- getCategoryTree缓存 -->
<cache name="getCategoryTree"
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="60"
timeToLiveSeconds="600"
overflowToDisk="true"
memoryStoreEvictionPolicy="LRU"/>
</ehcache>