Spring Boot アプリケーションで Simple Spring Memcached (SSM) を使用しています。私は memcached を初めて使用し、物事を理解しようとしています。
以下のコードの場合
@RestController
public class TestController {
@RequestMapping(value = "/checkend", method = RequestMethod.GET)
@Cacheable(value="defaultCache")
public String checkInteger(int Id){
RandomClass r = new RandomClass();
System.out.println("cache miss...");
return r.testCache("random");
}
}
public class RandomClass {
@Cacheable(value = "defaultCache")
public String testCache(String randomId){
System.out.println("came here ");
return "done1";
}
}
残りの呼び出しの後、例: localhost:9000/checkend?Id=7 memcached ストア (キーとして 7、値として "done1") が保存され、同じ残りの呼び出しが行われたときにキャッシュから取得されます..(注: RandomClass のメソッド「testCache」の結果「それはなぜですか?」)そして
@RequestMapping(value = "/checkend", method = RequestMethod.GET)
public String checkInteger(int Id){
RandomClass r = new RandomClass();
System.out.println("cache miss...");
return r.testCache("random");
}
}
public class RandomClass {
@Cacheable(value = "defaultCache")
public String testCache(String randomId){
System.out.println("came here ");
return "done1";
}
}
指定された入力で「testCache」メソッドをキャッシュしません。この場合の RandomClass のメソッドがキャッシュされない理由は何ですか?