package com.muyu.cache;/** * @author yuping * @package com.muyu.cache * @name CacheAbsBasic * @date 2024/9/29 20:10 抽象缓存层 */ import com.muyu.common.redis.service.RedisService; import org.springframework.beans.factory.annotation.Autowired; import java.util.List; import java.util.concurrent.ConcurrentHashMap; import static cn.hutool.core.lang.ansi.AnsiEncoder.encode; /** * @Author YuPing * @Description * @Version 1.0 * @Data 2024-09-29 20:10:09 */ public abstract class CacheAbsBasic implements CacheBasic{ @Autowired private RedisService redisService; // spring redis 工具类 @Override public void put(K key, V value) { redisService.setCacheObject(encodeKey(key), value); // 编码 --> 缓存基础的对象 Integer String 实体类等 } @Override public V get(K key) { return redisService.getCacheObject(encode(key)); // 获取缓存的基本对象 编码 } @Override public void remove(K key) { redisService.deleteObject(encode(key)); } }