2015-07-03 76 views
0

我想将我的请求存储在缓存中供将来参考,因为我的方法是无效的。我不知道如何。我的方法语法是:如何将请求参数存储在缓存中

@CacheEvict(key="Key",value="AirSegment",beforeInvocation=true) 
    private void cahingAndStoringSegment(String Key,TypeBaseAirSegment AirSegment){ 
    --- doing some operation 
} 

我是新的春季开机,所以请帮助我。

回答

1

目前尚不清楚你想要做什么。通常,您使用@Cacheable属性来防止您的方法在每次调用时转到缓慢的后端资源。 @Cacheable注解使用所有的方法参数作为键。但是,由于您的操作无效,因此您不清楚要缓存的内容。

@CacheEvict用于当你想调用一个方法来清除缓存。

还有@CachePut标签。 @CachePut(value = AirSegment,key = key)会将您操作中传递的AirSegment添加到缓存中。

http://docs.spring.io/spring/docs/current/spring-framework-reference/html/cache.html#cache-annotations-cacheable

如果你认为一个CRUD操作中,@Cachable将是对读操作使用,并在创建,更新和删除操作的@CacheEvict。