这是SHOP.COM 网站所使用的对象缓存系统,主要特性包括如下几个方面:
示例代码:
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)); }