💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、豆包、星火、月之暗面及文生图、文生视频 广告
~~~ 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); } } ~~~