Your SlideShare is downloading. ×

JSR 107 Caching Standard

6,143

Published on

This presentation explain the new feature of JSR 107 Caching Standards. …

This presentation explain the new feature of JSR 107 Caching Standards.

Published in: Technology, Business
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
6,143
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
13
Comments
0
Likes
3
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8
  • 2. The New JSR-107 Caching Standardレッドハット株式会社 木村 貴由日本オラクル株式会社 寺田 佳央 2 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8
  • 3. 以下の事項は、弊社の一般的な製品の方向性に関する概要を説明するものです。また、情報提供を唯一の目的とするものであり、いかなる契約にも組み込むことはできません。以下の事項は、マテリアルやコード、機能を提供することをコミットメント(確約)するものではないため、購買決定を行う際の判断材料になさらないで下さい。オラクル製品に関して記載されている機能の開発、リリースおよび時期については、弊社の裁量により決定されます。 OracleとJavaは、Oracle Corporation 及びその子会社、関連会社の米国及びその他の国における登録商標 です。文中の社名、商品名等は各社の商標または登録商標である場合があります。3 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8
  • 4. Program Agenda •  はじめに •  JSR-107 Caching の概要 •  JSR-107 Caching の詳細4 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8
  • 5. はじめに5 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8 5
  • 6. 6 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8
  • 7. 7 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8
  • 8. 8 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8
  • 9. 9 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8
  • 10. 10 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8
  • 11. 11 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8
  • 12. 12 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8
  • 13. JSR-107 の概要13 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8 5
  • 14. 仕様に関する情報入手先http://jcp.org/en/jsr/detail?id=107 14 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8
  • 15. 仕様に関する情報入手先http://tinyurl.com/7b5tenh https://github.com/jsr107 15 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8
  • 16. ConcurrentMapに類似 putIfAbsent() remove() replace() など16 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8
  • 17. どの位のサイズ?17 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8
  • 18. Java SE/EE 何れの環境でも利用可能http://tinyurl.com/7nkqzxc ※ Java SE 6/EE 6 以降18 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8
  • 19. スタート・ポイント <dependency>!   <groupId> javax.cache </groupId>!   <artifactId> cache-api </artifactId>!   <version> 0.5 </version> ← (2012/03/13 リリース)! </dependency> 19 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8
  • 20. Map に対する Cache の利点•  Atomic オペレーション (java.util.ConcurrentMapと類似)•  Read-through キャッシュ•  Write-through キャッシュ•  ライフサイクル•  キャッシュ・イベントリスナー•  統計情報20 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8
  • 21. オプションの機能•  トランザクション処理 (isolationレベルの指定)•  アノテーション (Spring/CDI)•  storeByReference (デフォルト storeByValue)21 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8
  • 22. 主要なAPI•  CacheManager –  キャッシュの検索、ライフサイクル管理など –  すべてのキャッシュは CacheManager に含まれる –  クラスタ環境では CacheMnagerがクラスタ化される•  CacheBuilder –  該当する CacheManager から Cacheを生成 –  Cache に関する各種追加設定が可能 •  有効期限設定、統計情報の有効・無効、トランザクションの有効・無効22 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8
  • 23. 主要なAPI •  Cache –  キャッシュ操作用のメソッドを提供 –  containsKey, get, getAll, getAndPut, getAndRemove, getAndReplace, getCacheManager, getConfiguration, getMBean, getName, getStatistics, invokeEntryProcess, iterator, load, loadAll, put, putAll, putifAbsent, registerCacheEntryListener, remove, removeAll, replace, unregisterCacheEntryListener, unwrap23 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8
  • 24. キャッシュのサンプル・コード String cacheName = "sampleCache";! CacheManager cacheManager = Caching.getCacheManager();! Cache<Integer, Date> cache = cacheManager.getCache(cacheName);!! if (cache == null) {! cache = cacheManager.! <Integer,Date>createCacheBuilder(cacheName).build();! }! Date value1 = new Date();! Integer key = 1;! cache.put(key, value1);! Date value2 = cache.get(key);! 24 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8
  • 25. JSR-107 の詳細25 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8 5
  • 26. キャッシュのイベント機構 •  CacheEntryCreatedListener •  CacheEntryRemovedListener •  CacheEntryReadListener •  CacheEntryUpdatedListener •  CacheEntryExpiredListener26 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8
  • 27. キャッシュのイベント機構 •  CacheEntryEvent –  Cache getSource() –  K getKey() –  V getValue()27 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8
  • 28. アノテーション •  @CacheResult •  @CachePut •  @CacheRemoveEntry •  @CacheRemoveAll28 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8
  • 29. アノテーションを使用しない場合 private Cache<Long, User> cache; !! public User findUser(long id){!   User user = cache.get(id);!   if ( user == null ) {!     user = …; // DB から指定された ID を元に検索!     cache.put(id, user); //キャッシュに ID と User を登録!   }!   return user;! }!29 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8
  • 30. アノテーションを使用する場合 @CacheResult(cacheName=”foo-cache")! public User findUser(long id) {!   User user = …; //DB から指定された ID を元に検索!   return user;! }!•  キャッシュに存在しない場合 –  メソッド内部処理を実行し実行結果をキャッシュ•  キャッシュに存在した場合 –  メソッドの内部は実行せずキャッシュの内容を返す30 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8
  • 31. ビジネスロジックへの適用例 @CacheDefaults(cacheName="blogManager")! public class BlogManager {! @CacheResult! public Blog getBlogEntry(String title) {...}! @CachePut! public void createEntry(@CacheKeyParam String title,! @CacheValue Blog blog) {...}! @CacheRemoveEntry! public void removeBlogEntry(String title) {...}! @CacheRemoveAll! public void removeAllBlogs() {...}! }31 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8
  • 32. トランザクション •  トランザクショナルリソースのキャッシュ •  データベース更新のシナリオ –  データベース更新 –  キャッシュ更新 –  データベースコミット失敗! •  キャッシュとキャッシュ対象の同期が必要32 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8
  • 33. デモ33 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8 5
  • 34. Twitter検索結果のキャッシュ(CDI) @Named! @RequestScoped! public class Eetter {!    @Inject!    private TwitterService twitter;!    private String query;!    private List<Tweet> tweets;!    private long searchTimeTaken;! ……続く!34 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8
  • 35. Twitter検索結果のキャッシュ(CDI) @Named! @RequestScoped! public class Eetter {!   ……(続き)!    public void search() throws Exception {!        long begin = System.currentTimeMillis();!        tweets = twitter.search(query);!        searchTimeTaken = ! System.currentTimeMillis() - begin;!    }}!35 } Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8
  • 36. キャッシュ用のアノテーション実装例 @CacheDefaults(cacheName="twitter")! public class TwitterService {!    @CacheResult!    public List<Tweet> search(String queryString) ! throws TwitterException {!        List<Tweet> tweets = ...; // Twitter検索を実行        return tweets;!    }! ……続く36 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8
  • 37. Twitter検索結果のキャッシュ(アノテーション)    ……続き!   @CacheRemoveEntry!    public void removeCache(String queryString) { }! !    @CacheRemoveAll!    public void clearCache() { }! }37 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8
  • 38. まとめ38 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8 5
  • 39. 想定する各社の実装製品 •  Terracotta - Ehcache •  JBoss ‒ Infinispan •  Oracle - Coherence •  IBM ‒ WebSphere eXtreme Scale •  SpringSource - Gemfire •  GridGain •  Google App Engine - memcache39 •  その他 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8
  • 40. まとめ•  JSR 107 : JCACHE - Java Temporary Caching API –  Java オブジェクトのキャッシュ –  Java アプリケーションの高速化を実現 –  高いスケーラビリティ –  DB キャッシュ以外の様々な場面で利用可能 –  ConcurrentMap のように簡単な操作性40 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8
  • 41. 参考情報 •  JSR 107 –  http://jcp.org/en/jsr/detail?id=107 •  Early Draft 仕様 –  http://tinyurl.com/7b5tenh •  ソースコード –  https://github.com/jsr107 •  スペックリード:Greg Luck のブログ –  http://gregluck.com/blog41 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8
  • 42. Russia 17–18 April 2012 India 3–4 May 2012 San Francisco September 30–October 4, 201242 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8
  • 43. 43 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8
  • 44. 44 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8

×