ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
~~~ package com.nobb.util.cache; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Component; @Component public class RedisCache { //jdk 序列化 @Autowired private RedisTemplate redisTemplate; //string 序列化,推荐这个 @Autowired private StringRedisTemplate stringRedisTemplate; public Integer set(String key,String value){ stringRedisTemplate.opsForValue().set(key,value); return 1; } public String get(String key){ return stringRedisTemplate.opsForValue().get(key); } } ~~~