Skip to content

Commit

Permalink
feature:Support_LRU_User_Info_Cache
Browse files Browse the repository at this point in the history
  • Loading branch information
cmgyqjj committed Sep 21, 2024
1 parent 5d77aac commit 9198e92
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.cache.Weigher;
import lombok.extern.slf4j.Slf4j;
import okhttp3.OkHttpClient;
import org.I0Itec.zkclient.ZkClient;
Expand All @@ -22,6 +23,7 @@
import org.springframework.data.redis.serializer.StringRedisSerializer;

import java.lang.reflect.Method;
import java.time.Duration;
import java.util.concurrent.TimeUnit;

import static com.crossoverjie.cim.route.constant.Constant.ACCOUNT_PREFIX;
Expand Down Expand Up @@ -112,8 +114,11 @@ public RouteHandle buildRouteHandle() throws Exception {
@Bean
public LoadingCache<Long, CIMUserInfo> USER_INFO_MAP(RedisTemplate<String, String> redisTemplate) {
return CacheBuilder.newBuilder()
.initialCapacity(64)
.maximumSize(1024)
.build(new CacheLoader<>() {
.concurrencyLevel(Runtime.getRuntime().availableProcessors())
.expireAfterWrite(10, TimeUnit.MINUTES)
.build(new CacheLoader<Long,CIMUserInfo>() {
@Override
public CIMUserInfo load(Long userId) throws Exception {
CIMUserInfo cimUserInfo = null;
Expand Down

0 comments on commit 9198e92

Please sign in to comment.