次のスプリングキャッシュ構成があります:
spring.cache.guava.spec: expireAfterWrite=1s
それから私はそれをテストしています:
@Test
public void test_not_work() {
callCachedMethod(..);
sleep(2s);
callCachedMethod(..);
expect("real method called TWO times");
// because cache should be expired after 1s
// It DOESN'T work, real method only called once
}
@Test
public void test_works() {
callCachedMethod(..);
sleep(2s);
callCachedMethod(..);
sleep(2s);
callCachedMethod(..);
expect("real method called THREE times");
// because cache should be expired after 1s
// IT WORKS!!
}
誰かがそれを説明できますか?