Optimize client cache capacity

pull/764/head
chen.ma 2 years ago
parent fd01bcdb2a
commit 50746f41fe

@ -19,7 +19,6 @@ package cn.hippo4j.config.service;
import com.github.benmanes.caffeine.cache.Cache; import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine; import com.github.benmanes.caffeine.cache.Caffeine;
import lombok.NonNull;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -36,20 +35,21 @@ import static cn.hippo4j.common.constant.Constants.WEIGHT_CONFIGS;
@RequiredArgsConstructor @RequiredArgsConstructor
public class ConfigServletInner { public class ConfigServletInner {
@NonNull
private final LongPollingService longPollingService; private final LongPollingService longPollingService;
private static final int CLIENT_IDENTIFY_MAXIMUM_SIZE = 16384;
private final Cache<String, Long> deWeightCache = Caffeine.newBuilder() private final Cache<String, Long> deWeightCache = Caffeine.newBuilder()
.maximumSize(1024) .maximumSize(CLIENT_IDENTIFY_MAXIMUM_SIZE)
.build(); .build();
/** /**
* Poll configuration. * Poll configuration.
* *
* @param request * @param request http servlet request
* @param response * @param response http servlet response
* @param clientMd5Map * @param clientMd5Map client md5 map
* @param probeRequestSize * @param probeRequestSize probe request size
* @return * @return
*/ */
public String doPollingConfig(HttpServletRequest request, HttpServletResponse response, Map<String, String> clientMd5Map, int probeRequestSize) { public String doPollingConfig(HttpServletRequest request, HttpServletResponse response, Map<String, String> clientMd5Map, int probeRequestSize) {
@ -66,7 +66,7 @@ public class ConfigServletInner {
* When a user proposes to deploy in the company environment, the same request will be called repeatedly. * When a user proposes to deploy in the company environment, the same request will be called repeatedly.
* This problem belongs to an extremely individual scenario. Since it cannot be reproduced, so first solve the problem in this way. * This problem belongs to an extremely individual scenario. Since it cannot be reproduced, so first solve the problem in this way.
* *
* @param request * @param request http servlet request
* @return * @return
*/ */
private boolean weightVerification(HttpServletRequest request) { private boolean weightVerification(HttpServletRequest request) {

Loading…
Cancel
Save