@Service @CacheConfig(cacheNames="user") public class RedisAn { public Map<String, User> map = new HashMap<>(); public void insert(User user){ map.put(user.getId(), user); } @Cacheable(key = "'id_'+#id") public User get(String id){ System.out.println("get被調用了"); return map.get(id); } @CacheEvict(key = "'id_'+#id") public User del(String id){ return map.remove(id); } @CacheEvict(allEntries=true) public void delAll(){ } public Map<String, User> getMap() { return map; } public void setMap(Map<String, User> map) { this.map = map; }