2015-07-03 84 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。