소스 검색

代码优化

woody 4 달 전
부모
커밋
c4c74b371d

+ 0 - 86
framework-base/src/main/java/com/chelvc/framework/base/annotation/Group.java

@@ -1,86 +0,0 @@
-package com.chelvc.framework.base.annotation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import com.chelvc.framework.base.group.GroupHandler;
-import com.chelvc.framework.base.group.SimpleGroupHandler;
-import com.chelvc.framework.common.model.Invoking;
-import com.chelvc.framework.common.model.Platform;
-import com.chelvc.framework.common.model.Terminal;
-
-/**
- * 场景分组注解
- *
- * @author Woody
- * @date 2024/9/8
- */
-@Documented
-@Target({})
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Group {
-    /**
-     * 获取分组场景
-     *
-     * @return 分组场景
-     */
-    String scene();
-
-    /**
-     * 是否异步分组
-     *
-     * @return true/false
-     */
-    boolean async() default false;
-
-    /**
-     * 是否需要存储
-     *
-     * @return true/false
-     */
-    boolean storing() default false;
-
-    /**
-     * 获取渠道数组
-     *
-     * @return 渠道数组
-     */
-    String[] channels() default {};
-
-    /**
-     * 获取版本数组
-     *
-     * @return 版本数组
-     */
-    Version[] versions() default {};
-
-    /**
-     * 获取平台数组
-     *
-     * @return 平台数组
-     */
-    Platform[] platforms() default {};
-
-    /**
-     * 获取终端数组
-     *
-     * @return 终端数组
-     */
-    Terminal[] terminals() default {};
-
-    /**
-     * 获取分组时机
-     *
-     * @return 分组时机
-     */
-    Invoking invoking() default Invoking.REQUEST;
-
-    /**
-     * 获取分组处理器
-     *
-     * @return 分组处理器对象
-     */
-    Class<? extends GroupHandler> handler() default SimpleGroupHandler.class;
-}

+ 0 - 25
framework-base/src/main/java/com/chelvc/framework/base/annotation/Groups.java

@@ -1,25 +0,0 @@
-package com.chelvc.framework.base.annotation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * 多场景分组注解
- *
- * @author Woody
- * @date 2024/9/8
- */
-@Documented
-@Target(ElementType.METHOD)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Groups {
-    /**
-     * 获取场景分组数组
-     *
-     * @return 场景分组数组
-     */
-    Group[] value();
-}

+ 0 - 8
framework-base/src/main/java/com/chelvc/framework/base/config/ApplicationConfigurer.java

@@ -5,8 +5,6 @@ import javax.servlet.Filter;
 
 import com.chelvc.framework.base.context.DefaultSessionFactory;
 import com.chelvc.framework.base.context.SessionFactory;
-import com.chelvc.framework.base.group.GroupStore;
-import com.chelvc.framework.base.group.MemoryGroupStore;
 import com.chelvc.framework.base.interceptor.ResponseWrapInterceptor;
 import com.chelvc.framework.common.util.JacksonUtils;
 import com.chelvc.framework.common.util.ObjectUtils;
@@ -42,12 +40,6 @@ public class ApplicationConfigurer {
         return JacksonUtils.initializeSerializer(builder.build(), safely);
     }
 
-    @Bean
-    @ConditionalOnMissingBean(GroupStore.class)
-    public GroupStore groupStore() {
-        return new MemoryGroupStore();
-    }
-
     @Bean
     @ConditionalOnMissingBean(SessionFactory.class)
     public SessionFactory sessionFactory() {

+ 0 - 23
framework-base/src/main/java/com/chelvc/framework/base/context/GroupEvent.java

@@ -1,23 +0,0 @@
-package com.chelvc.framework.base.context;
-
-import com.chelvc.framework.common.model.Caps;
-import lombok.Getter;
-import lombok.NonNull;
-
-/**
- * 场景分组事件
- *
- * @author Woody
- * @date 2024/11/29
- */
-@Getter
-public class GroupEvent extends BasicEvent {
-    private final String scene;
-    private final Caps group;
-
-    public GroupEvent(@NonNull Object source, @NonNull String scene, @NonNull Caps group) {
-        super(source);
-        this.scene = scene;
-        this.group = group;
-    }
-}

+ 0 - 21
framework-base/src/main/java/com/chelvc/framework/base/context/GroupEventListener.java

@@ -1,21 +0,0 @@
-package com.chelvc.framework.base.context;
-
-import org.springframework.context.ApplicationListener;
-import org.springframework.stereotype.Component;
-
-/**
- * 场景分组事件监听器
- *
- * @author Woody
- * @date 2024/12/3
- */
-@Component
-public class GroupEventListener implements ApplicationListener<GroupEvent> {
-    @Override
-    public void onApplicationEvent(GroupEvent event) {
-        Session session = SessionContextHolder.getSession(false);
-        if (session != null) {
-            session.setGroup(event.getScene(), event.getGroup());
-        }
-    }
-}

+ 9 - 13
framework-base/src/main/java/com/chelvc/framework/base/context/Session.java

@@ -2,13 +2,14 @@ package com.chelvc.framework.base.context;
 
 import java.io.Serializable;
 import java.util.Collections;
+import java.util.Map;
 import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
 
 import com.chelvc.framework.common.model.Caps;
 import com.chelvc.framework.common.model.Platform;
 import com.chelvc.framework.common.model.Terminal;
-import com.chelvc.framework.common.util.ObjectUtils;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.google.common.collect.Maps;
 import lombok.AccessLevel;
 import lombok.AllArgsConstructor;
 import lombok.Builder;
@@ -98,9 +99,11 @@ public class Session implements Serializable {
     /**
      * 分组场景/标识映射表
      */
+    @JsonIgnore
+    @Builder.Default
     @Getter(AccessLevel.NONE)
     @Setter(AccessLevel.NONE)
-    private ConcurrentHashMap<String, Caps> groups;
+    private final Map<String, Caps> groups = Maps.newConcurrentMap();
 
     /**
      * 获取场景分组
@@ -108,8 +111,8 @@ public class Session implements Serializable {
      * @param scene 分组场景
      * @return 分组标识
      */
-    Caps getGroup(@NonNull String scene) {
-        return ObjectUtils.isEmpty(this.groups) ? null : this.groups.get(scene);
+    public Caps getGroup(@NonNull String scene) {
+        return this.groups.get(scene);
     }
 
     /**
@@ -118,14 +121,7 @@ public class Session implements Serializable {
      * @param scene 分组场景
      * @param group 分组标识
      */
-    void setGroup(@NonNull String scene, @NonNull Caps group) {
-        if (this.groups == null) {
-            synchronized (this) {
-                if (this.groups == null) {
-                    this.groups = new ConcurrentHashMap<>();
-                }
-            }
-        }
+    public void setGroup(@NonNull String scene, @NonNull Caps group) {
         this.groups.put(scene, group);
     }
 

+ 0 - 22
framework-base/src/main/java/com/chelvc/framework/base/context/SessionContextHolder.java

@@ -14,8 +14,6 @@ import javax.servlet.ServletRequestListener;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import com.chelvc.framework.base.group.GroupStore;
-import com.chelvc.framework.common.model.Caps;
 import com.chelvc.framework.common.model.Compare;
 import com.chelvc.framework.common.model.Platform;
 import com.chelvc.framework.common.model.Terminal;
@@ -573,26 +571,6 @@ public class SessionContextHolder implements ServletRequestListener {
         return ObjectUtils.ifNull(attributes, ServletRequestAttributes::getResponse);
     }
 
-    /**
-     * 获取场景分组
-     *
-     * @param scene 分组场景
-     * @return 分组标识
-     */
-    public static Caps getGroup(@NonNull String scene) {
-        Session session = getSession(false);
-        if (session == null) {
-            return null;
-        }
-        Caps group = session.getGroup(scene);
-        if (group == null) {
-            GroupStore store = ApplicationContextHolder.getBean(GroupStore.class);
-            group = ObjectUtils.ifNull(store.get(scene), Caps.NONE);
-            session.setGroup(scene, group);
-        }
-        return group == Caps.NONE ? null : group;
-    }
-
     /**
      * 获取请求参数
      *

+ 0 - 20
framework-base/src/main/java/com/chelvc/framework/base/group/GroupHandler.java

@@ -1,20 +0,0 @@
-package com.chelvc.framework.base.group;
-
-import com.chelvc.framework.common.model.Caps;
-
-/**
- * 分组处理器接口
- *
- * @author Woody
- * @date 2024/9/8
- */
-public interface GroupHandler {
-    /**
-     * 执行分组
-     *
-     * @param scene 分组场景
-     * @param args  方法输入/出参数数组
-     * @return 分组结果
-     */
-    Caps execute(String scene, Object... args);
-}

+ 0 - 47
framework-base/src/main/java/com/chelvc/framework/base/group/GroupStore.java

@@ -1,47 +0,0 @@
-package com.chelvc.framework.base.group;
-
-import java.util.Collection;
-import java.util.Map;
-
-import com.chelvc.framework.common.model.Caps;
-
-/**
- * 场景分组存储接口
- *
- * @author Woody
- * @date 2024/11/23
- */
-public interface GroupStore {
-    /**
-     * 获取分组标识
-     *
-     * @param scene 场景标识
-     * @return 分组标识
-     */
-    Caps get(String scene);
-
-    /**
-     * 批量获取分组标识
-     *
-     * @param scenes 分组场景集合
-     * @return 分组场景/标识映射表
-     */
-    Map<String, Caps> get(Collection<String> scenes);
-
-    /**
-     * 设置分组标识,如果分组不存在则设置分组,否则忽略
-     *
-     * @param scene 分组场景
-     * @param group 分组标识
-     * @return 分组标识
-     */
-    Caps set(String scene, Caps group);
-
-    /**
-     * 批量设置分组标识,如果分组不存在则设置分组,否则忽略
-     *
-     * @param groups 分组场景/标识映射表
-     * @return 分组场景/标识映射表
-     */
-    Map<String, Caps> set(Map<String, Caps> groups);
-}

+ 0 - 67
framework-base/src/main/java/com/chelvc/framework/base/group/MemoryGroupStore.java

@@ -1,67 +0,0 @@
-package com.chelvc.framework.base.group;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-import com.chelvc.framework.base.context.SessionContextHolder;
-import com.chelvc.framework.common.model.Caps;
-import com.chelvc.framework.common.util.ObjectUtils;
-import com.google.common.collect.Maps;
-import lombok.NonNull;
-
-/**
- * 基于内存场景分组存储实现
- *
- * @author Woody
- * @date 2024/11/24
- */
-public class MemoryGroupStore implements GroupStore {
-    private final Map<Long, Map<String, Caps>> cache = Maps.newConcurrentMap();
-
-    @Override
-    public Caps get(@NonNull String scene) {
-        Long id = SessionContextHolder.getId();
-        if (id == null) {
-            return null;
-        }
-        return ObjectUtils.ifNull(this.cache.get(id), groups -> groups.get(scene));
-    }
-
-    @Override
-    public Map<String, Caps> get(@NonNull Collection<String> scenes) {
-        if (ObjectUtils.isEmpty(scenes)) {
-            return Collections.emptyMap();
-        }
-        Long id = SessionContextHolder.getId();
-        if (id == null) {
-            return Collections.emptyMap();
-        }
-        Map<String, Caps> groups = ObjectUtils.ifNull(this.cache.get(id), Collections::emptyMap);
-        return scenes.stream().collect(Collectors.toMap(scene -> scene, groups::get));
-    }
-
-    @Override
-    public Caps set(@NonNull String scene, @NonNull Caps group) {
-        Long id = SessionContextHolder.getId();
-        if (id == null) {
-            return group;
-        }
-        Map<String, Caps> groups = this.cache.get(id);
-        if (groups == null) {
-            groups = this.cache.computeIfAbsent(id, k -> Maps.newConcurrentMap());
-        }
-        return groups.computeIfAbsent(scene, k -> group);
-    }
-
-    @Override
-    public Map<String, Caps> set(@NonNull Map<String, Caps> groups) {
-        if (ObjectUtils.isEmpty(groups)) {
-            return Collections.emptyMap();
-        }
-        Map<String, Caps> values = Maps.newHashMapWithExpectedSize(groups.size());
-        groups.forEach((scene, group) -> values.put(scene, this.set(scene, group)));
-        return values;
-    }
-}

+ 0 - 22
framework-base/src/main/java/com/chelvc/framework/base/group/SimpleGroupHandler.java

@@ -1,22 +0,0 @@
-package com.chelvc.framework.base.group;
-
-import com.chelvc.framework.base.context.SessionContextHolder;
-import com.chelvc.framework.common.model.Caps;
-
-/**
- * 分组处理器简单实现
- *
- * @author Woody
- * @date 2024/9/8
- */
-public class SimpleGroupHandler implements GroupHandler {
-    @Override
-    public Caps execute(String scene, Object... args) {
-        Long id = SessionContextHolder.getId();
-        if (id == null) {
-            return null;
-        }
-        int mod = (int) Math.abs(id % 2);
-        return mod == 0 ? Caps.A : Caps.B;
-    }
-}

+ 0 - 196
framework-base/src/main/java/com/chelvc/framework/base/interceptor/BusinessGroupInterceptor.java

@@ -1,196 +0,0 @@
-package com.chelvc.framework.base.interceptor;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import com.chelvc.framework.base.annotation.Group;
-import com.chelvc.framework.base.annotation.Groups;
-import com.chelvc.framework.base.context.ApplicationContextHolder;
-import com.chelvc.framework.base.context.GroupEvent;
-import com.chelvc.framework.base.context.SessionContextHolder;
-import com.chelvc.framework.base.context.ThreadContextHolder;
-import com.chelvc.framework.base.group.GroupHandler;
-import com.chelvc.framework.base.group.GroupStore;
-import com.chelvc.framework.common.model.Caps;
-import com.chelvc.framework.common.model.Invoking;
-import com.chelvc.framework.common.util.ObjectUtils;
-import com.chelvc.framework.common.util.StringUtils;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.aspectj.lang.ProceedingJoinPoint;
-import org.aspectj.lang.annotation.Around;
-import org.aspectj.lang.annotation.Aspect;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.ApplicationContext;
-import org.springframework.stereotype.Component;
-
-/**
- * 用户业务分组拦截器
- *
- * @author Woody
- * @date 2024/11/24
- */
-@Slf4j
-@Aspect
-@Component
-@RequiredArgsConstructor(onConstructor = @__(@Autowired))
-public class BusinessGroupInterceptor {
-    private final GroupStore store;
-    private final ApplicationContext applicationContext;
-    private final Map<Class<?>, GroupHandler> handlers = Maps.newConcurrentMap();
-
-    /**
-     * 判断请求是否匹配分组
-     *
-     * @param group 分组注解实例
-     * @return true/false
-     */
-    private boolean matches(Group group) {
-        return StringUtils.notEmpty(group.scene())
-                && (ObjectUtils.isEmpty(group.channels()) || SessionContextHolder.isChannel(group.channels()))
-                && (ObjectUtils.isEmpty(group.versions()) || SessionContextHolder.isVersion(group.versions()))
-                && (ObjectUtils.isEmpty(group.platforms()) || SessionContextHolder.isPlatform(group.platforms()))
-                && (ObjectUtils.isEmpty(group.terminals()) || SessionContextHolder.isTerminal(group.terminals()));
-    }
-
-    /**
-     * 初始化分组处理器
-     *
-     * @param type 处理器类型
-     * @return 分组处理器实例
-     */
-    private GroupHandler initializeGroupHandler(Class<? extends GroupHandler> type) {
-        GroupHandler handler = ApplicationContextHolder.getBean(this.applicationContext, type, false);
-        if (handler == null && (handler = this.handlers.get(type)) == null) {
-            handler = this.handlers.computeIfAbsent(type, k -> ObjectUtils.instance(type));
-        }
-        return handler;
-    }
-
-    /**
-     * 执行分组逻辑
-     *
-     * @param target 拦截目标
-     * @param groups 分组注解列表
-     * @param args   分组执行参数
-     */
-    private void execute(Object target, List<Group> groups, Object... args) {
-        Map<String, Caps> stores = null;
-        for (Group group : groups) {
-            try {
-                GroupHandler handler = this.initializeGroupHandler(group.handler());
-                Caps value = handler.execute(group.scene(), args);
-                if (value != null && group.storing()) {
-                    if (stores == null) {
-                        stores = Maps.newHashMapWithExpectedSize(groups.size());
-                    }
-                    stores.put(group.scene(), value);
-                } else {
-                    value = ObjectUtils.ifNull(value, Caps.NONE);
-                    this.applicationContext.publishEvent(new GroupEvent(target, group.scene(), value));
-                }
-            } catch (Exception e) {
-                log.error("Business group handle failed: {}", group.scene(), e);
-            }
-        }
-        try {
-            stores = ObjectUtils.ifEmpty(stores, this.store::set, Collections::emptyMap);
-            stores.forEach((scene, group) -> {
-                group = ObjectUtils.ifNull(group, Caps.NONE);
-                this.applicationContext.publishEvent(new GroupEvent(target, scene, group));
-            });
-        } catch (Exception e) {
-            log.error("Business group handle failed", e);
-        }
-    }
-
-    /**
-     * 执行分组逻辑
-     *
-     * @param target   拦截目标
-     * @param invoking 分组时间点
-     * @param groups   分组注解列表
-     * @param args     分组执行参数
-     */
-    private void execute(Object target, Invoking invoking, List<Group> groups, Object... args) {
-        List<Group> sync = null, async = null;
-        for (Group group : groups) {
-            if (group.invoking() == invoking) {
-                if (group.async()) {
-                    if (async == null) {
-                        async = Lists.newLinkedList();
-                    }
-                    async.add(group);
-                } else {
-                    if (sync == null) {
-                        sync = Lists.newLinkedList();
-                    }
-                    sync.add(group);
-                }
-            }
-        }
-        if (ObjectUtils.notEmpty(async)) {
-            List<Group> copy = async;
-            ThreadContextHolder.run(() -> this.execute(target, copy, args));
-        }
-        if (ObjectUtils.notEmpty(sync)) {
-            this.execute(target, sync, args);
-        }
-    }
-
-    /**
-     * 方法调用分组拦截
-     *
-     * @param point  方法拦截点
-     * @param groups 分组注解实例
-     * @return 方法调用结果
-     * @throws Throwable 方法调用异常
-     */
-    @Around("@annotation(groups)")
-    public Object intercept(ProceedingJoinPoint point, Groups groups) throws Throwable {
-        if (Objects.isNull(SessionContextHolder.getId())) {
-            return point.proceed(point.getArgs());
-        }
-
-        // 获取匹配的分组注解列表
-        List<Group> matches = Stream.of(groups.value()).filter(this::matches)
-                .collect(Collectors.toCollection(Lists::newLinkedList));
-        if (ObjectUtils.isEmpty(matches)) {
-            return point.proceed(point.getArgs());
-        }
-
-        // 获取已存储分组结果
-        Object target = point.getTarget();
-        try {
-            Set<String> scenes = matches.stream().filter(Group::storing).map(Group::scene).collect(Collectors.toSet());
-            Map<String, Caps> stores = ObjectUtils.ifEmpty(scenes, this.store::get, Collections::emptyMap);
-            stores.forEach((scene, group) -> {
-                if (group != null) {
-                    matches.removeIf(annotation -> Objects.equals(annotation.scene(), scene));
-                    this.applicationContext.publishEvent(new GroupEvent(target, scene, group));
-                }
-            });
-        } catch (Exception e) {
-            log.error("Business group handle failed", e);
-            return point.proceed(point.getArgs());
-        }
-
-        // 执行分组逻辑(方法调用前后)
-        Object[] args = point.getArgs();
-        if (ObjectUtils.notEmpty(matches)) {
-            this.execute(target, Invoking.REQUEST, matches, args);
-        }
-        Object value = point.proceed(args);
-        if (ObjectUtils.notEmpty(matches)) {
-            this.execute(target, Invoking.RESPONSE, matches, value);
-        }
-        return value;
-    }
-}

+ 0 - 120
framework-redis/src/main/java/com/chelvc/framework/redis/cache/RedisGroupStore.java

@@ -1,120 +0,0 @@
-package com.chelvc.framework.redis.cache;
-
-import java.time.Duration;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import com.chelvc.framework.base.context.SessionContextHolder;
-import com.chelvc.framework.base.group.GroupStore;
-import com.chelvc.framework.common.model.Caps;
-import com.chelvc.framework.common.util.ObjectUtils;
-import com.chelvc.framework.common.util.StringUtils;
-import com.chelvc.framework.redis.context.RedisContextHolder;
-import com.chelvc.framework.redis.context.RedisHashHolder;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import lombok.NonNull;
-import org.springframework.data.redis.core.HashOperations;
-import org.springframework.data.redis.core.RedisTemplate;
-
-/**
- * 场景分组存储Redis缓存实现
- *
- * @author Woody
- * @date 2024/11/28
- */
-public class RedisGroupStore implements GroupStore {
-    private final GroupStore delegate;
-
-    public RedisGroupStore(@NonNull GroupStore delegate) {
-        this.delegate = delegate;
-    }
-
-    /**
-     * 获取Redis用户分组标识
-     *
-     * @return Redis标识
-     */
-    private String key() {
-        Long id = SessionContextHolder.getId();
-        return id == null ? null : ("group:" + id);
-    }
-
-    @Override
-    public Caps get(@NonNull String scene) {
-        String key = this.key();
-        if (StringUtils.isEmpty(key)) {
-            return null;
-        }
-
-        // 获取分组标识,如果缓存不存在则重新加载分组并更新缓存
-        RedisTemplate<String, Object> template = RedisContextHolder.getDefaultTemplate();
-        Caps group = (Caps) template.opsForHash().get(key, scene);
-        if (group == null && (group = this.delegate.get(scene)) != null) {
-            RedisHashHolder.set(template, key, scene, group, Duration.ofDays(1));
-        }
-        return group;
-    }
-
-    @Override
-    public Map<String, Caps> get(@NonNull Collection<String> scenes) {
-        String key = this.key();
-        if (StringUtils.isEmpty(key) || ObjectUtils.isEmpty(scenes)) {
-            return Collections.emptyMap();
-        }
-
-        // 批量获取缓存分组映射
-        List<String> nones = Lists.newLinkedList();
-        Map<String, Caps> mapping = Maps.newHashMapWithExpectedSize(scenes.size());
-        RedisTemplate<String, Object> template = RedisContextHolder.getDefaultTemplate();
-        HashOperations<String, String, Caps> operations = template.opsForHash();
-        List<Caps> groups = operations.multiGet(key, scenes);
-        int i = 0;
-        for (String scene : scenes) {
-            Caps group = ObjectUtils.isEmpty(groups) ? null : groups.get(i++);
-            if (group == null) {
-                nones.add(scene);
-            } else {
-                mapping.put(scene, group);
-            }
-        }
-
-        // 重新加载场景分组为null的数据
-        if (ObjectUtils.notEmpty(nones)) {
-            Map<String, Caps> reloads = this.delegate.get(nones);
-            if (ObjectUtils.notEmpty(reloads)) {
-                mapping.putAll(reloads);
-                RedisHashHolder.set(template, key, reloads, Duration.ofDays(1));
-            }
-        }
-        return mapping;
-    }
-
-    @Override
-    public Caps set(@NonNull String scene, @NonNull Caps group) {
-        String key = this.key();
-        if (StringUtils.isEmpty(key)) {
-            return group;
-        }
-
-        // 重置场景分组并更新缓存
-        group = this.delegate.set(scene, group);
-        RedisHashHolder.set(RedisContextHolder.getDefaultTemplate(), key, scene, group, Duration.ofDays(1));
-        return group;
-    }
-
-    @Override
-    public Map<String, Caps> set(@NonNull Map<String, Caps> groups) {
-        String key = this.key();
-        if (StringUtils.isEmpty(key)) {
-            return groups;
-        }
-
-        // 重置场景分组并更新缓存
-        groups = this.delegate.set(groups);
-        RedisHashHolder.set(RedisContextHolder.getDefaultTemplate(), key, groups, Duration.ofDays(1));
-        return groups;
-    }
-}