Help us understand the problem. What is going on with this article?

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);

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

hogelog
hogelog http://hogel.org/
http://hogel.org/
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
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  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
ユーザーは見つかりませんでした