Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
3
Help us understand the problem. What is going on with this article?
@hogelog

Javaでメモしたい

More than 5 years have passed since last update.
memo1.java
HogeService hogeService = new HogeService();
MemoizeService memo = new MemoizeService();

public void hoge(Integer hogeId) {
  // HogeService.getHoge を呼ぶ
  Hoge hoge = memo.wrap(hogeService).getHoge(hogeId);

  //...

  fuga(hogeId);
}
public void fuga(Integer hogeId) {
  // HogeService.getHoge を呼ばずに先の値を返す
  Hoge hoge = memo.wrap(hogeService).getHoge(hogeId);

  //...
}

こういうことをしたい。

memo2.java
MemoizeService memo = new MemoizeService();
HogeService hogeService = memo(new HogeService());

とかするのは嫌だ。

なんかできそうな気もする。なんか既にそういういい感じのないかな。

キャッシュ寿命

memo3.java
  Hoge hoge = memo.requestScope(hogeService).getHoge(hogeId);
  Hoge hoge2 = memo.eternal(hogeService).getHoge(hogeId);

こんな感じでウェブアプリケーション内で使っている時に同一リクエスト間だけ有効なキャッシュになるとか、ずっと保持しておくとか適当に制御できると嬉しい。
まあどちらかというと後者はどうとでもなるので、前者の同一リクエスト間だけ有効なキャッシュとかやりたい。

3
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
hogelog
hogelog http://hogel.org/

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
3
Help us understand the problem. What is going on with this article?