清除redis spring数据中特定缓存名称的缓存

9avjhtql  于 2021-06-10  发布在  Redis
关注(0)|答案(0)|浏览(344)

我有下面的方法来缓存 student-classes ,我只想清除 student-classes ```
@Cacheable( value = "getStudentClasses",key ="(new net.student.util.CacheKeyCreator()).createKey(''+#university)",cacheManager = "cacheManager")
public List getStudentClasses(String university) {
//get studentclasses
}

我尝试如下清除,但它没有清除具有特定名称的缓存

@Bean(name = "cacheManager")
public CacheManager cacheManager ( RedisTemplate<String, Object> redisTemplate ) {
RedisCacheManager redisCacheManager = new RedisCacheManager( redisTemplate );
redisCacheManager.setDefaultExpiration(0);
redisCacheManager.setUsePrefix( true);
return redisCacheManager;
}

@Autowired
ApplicationContext context;

public void clearStudentClasses(){

CacheManager cacheManager= (CacheManager) context.getBean("cacheManager");

cacheManager.getCache("getStudentClasses").clear(); //exceptionLine

}

我在例外行得到了这个例外

org.springframework.dao.InvalidDataAccessApiUsageException: ERR
unknown command 'EVAL'; nested exception is
redis.clients.jedis.exceptions.JedisDataException: ERR unknown command
'EVAL'

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题