Apache JCS

1,063 views
857 views

Published on

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

  • Be the first to like this

No Downloads
Views
Total views
1,063
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
6
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Apache JCS

  1. 1. Apache JCS UI Caching
  2. 2. 1. JCS - What is it? 2. UI Caching - What is it? 3. Problems - What we got! 4. Solutions - What we found! 5. The one - What we chose! 6. Implementation - What we done! The questions of this topic
  3. 3. JCS is a distributed caching system written in java. The JCS goes beyond simply caching objects in memory. It provides numerous additional features: • Memory management • Disk overflow (and defragmentation) • Thread pool controls • Element groupingand e.t.c. http://commons.apache.org/jcs/ JCS
  4. 4. STEP 1: Understand the Core Concepts STEP 2: Download JCS STEP 3: Get the Required Dependencies STEP 4: Configure JCS Configuration parts of file: 1. DEFAULT CACHE REGION 2. PRE-DEFINED CACHE REGIONS 3. AVAILABLE AUXILIARY CACHES JCS: Getting started
  5. 5. Region: 1. cacheattributes.MemoryCacheName ; 2. elementattributes.IsEternal; 3. elementattributes.MaxLifeSeconds; Auxiliary: 4. jcs.auxiliary (factory); 5. jcs.auxiliary.(..).attributes (attributes); 6. attributes.OptimizeAtRemoveCount. Most Interesting Parameters of Region and Auxiliary
  6. 6. UI Caching
  7. 7. You can use cache in three ways: 1. put once and do not change it (no problem); 2. put every time new data by new key (no problem); 3. put every time new data by same key (problems will be if you used file caching). How We Used the Cache
  8. 8. Problem: our cache file was grown very fast. Task: make it the fixed size or try to do it not so big because information in this region about few megabytes. So we have to optimize size of cache file. But how? optimization file we can use only when we load cache and if we use method remove: jcs.auxiliary.(..).attributes.OptimizeAtRemoveCount=2000 jcs.auxiliary.(..).attributes.OptimizeOnShutdown=true Problems
  9. 9. We restart our application not often, so way with restart attribute is not suitable. Optimize after removes - it's good. BUT... In some situation We don't remove from cache we just replace data. So how to optimize file? Problems 2
  10. 10. 1. try to fix this using parameters; 2. try to organize structure to force deleting cache files; 3. try to create new parameters and fix it by them; Solutions
  11. 11. 1. Create new classes with new functionality extend or implements these ones: org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCache; org.apache.jcs.auxiliary.AuxiliaryCacheFactory; org.apache.jcs.auxiliary.AuxiliaryCacheManager; org.apache.jcs.auxiliary.AuxiliaryCacheAttributes. 2. Add this classes to configuration file: jcs.auxiliary.(..)=com.sperasoft.ui.cache .OptimizationIndexedDiskCacheFactory jcs.auxiliary.(..).attributes= com.sperasoft.ui .cache.OptimizationIndexedDiskCacheAttributes Implementation 1
  12. 12. 3. added new attribute to configuration file: jcs.auxiliary.DC.attributes. OptimizationTimeout=28800 This attribute contain information how often cache how to optimize file. Time sets in second. 4. Write a documentation. Implementation 2
  13. 13. We just added new property for JCS that say how often we want to optimize cache file and added realization of calling standard method of DiskCache. So if you need to extend JCS – just do it. Our Implementation
  14. 14. Slideshare - https://www.slideshare.net/Sperasoft/ SpeakerDeck - https://speakerdeck.com/sperasoft GitHub - http://github.com/sperasoft Check out more knowledge sharing here: Company site - http://www.sperasoft.com/ On Facebook - https://facebook.com/sperasoft On Twitter - http://twitter.com/sperasoft Learn more about Sperasoft:

×