Java緩存系統 SHOP.COM Cache System
這是SHOP.COM 網站所使用的對象緩存系統,主要特性包括如下幾個方面:
* 支持進程內和CS 模式的緩存結構
* 可以進行水平擴展
* 緩存對象可被存到磁盤中
* 支持關聯主鍵
* 非事務
* 支持任意長度的主鍵和鍵值
* 根據 TTL 進行自動垃圾回收
* 可以運行于容器中或者是獨立平臺運行
示例代碼:
List<SCClientManager> clientSet = new ArrayList<SCClientManager>(); SCClientFactory clientFactory = ShopComCacheFactory.getClientFactory(); SCClientContext context = clientFactory.newContext(); context.address(new InetSocketAddress(/*address 1*/, /*port number 1*/)); SCClientManager manager = clientFactory.newClientManager(context); clientSet.add(manager); // add additional managers for each cache server myCache = new SCCache(new SCMultiManager(clientSet)); // see if your object is in the cache MyObject obj = (MyObject)myCache.get(new SCDataBlock(myKey)); // if it's not, allocate it and add it to the cache if ( obj == null ) { obj = new MyObject(); myCache.put(new SCDataBlock(myKey, obj)); }
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!