public Object read(Object key) throws CacheException { try { return cache.get(new Fqn(regionFqn, key), ITEM); } catch (Exception e) { throw new CacheException(e); } }
public void update(Object key, Object value) throws CacheException { try { cache.put(new Fqn(regionFqn, key), ITEM, value); } catch (Exception e) { throw new CacheException(e); } }
public void clear() throws CacheException { try { cache.remove(regionFqn); } catch (Exception e) { throw new CacheException(e); } }
public void remove(Object key) throws CacheException { try { cache.remove(new Fqn(regionFqn, key)); } catch (Exception e) { throw new CacheException(e); } }
@SuppressWarnings("unchecked") public Map toMap() { try { Map result = new HashMap(); Set childrenNames = cache.getChildrenNames(regionFqn); if (childrenNames != null) { Iterator iter = childrenNames.iterator(); while (iter.hasNext()) { Object key = iter.next(); result.put(key, cache.get(new Fqn(regionFqn, key), ITEM)); } } return result; } catch (Exception e) { throw new CacheException(e); } }
public long getElementCountInMemory() { try { Set children = cache.getChildrenNames(regionFqn); return children == null ? 0 : children.size(); } catch (Exception e) { throw new CacheException(e); } }
@SuppressWarnings("deprecation") public void put(Object key, Object value) throws CacheException { Transaction tx = suspend(); try { // Workaround for JBCACHE-785 cache.getInvocationContext().setTransaction(null); cache.getInvocationContext().setGlobalTransaction(null); // do the failfast put outside the scope of the JTA txn cache.putFailFast(new Fqn(regionFqn, key), ITEM, value, 0); } catch (TimeoutException te) { // ignore! log.debug("ignoring write lock acquisition failure"); } catch (Exception e) { throw new CacheException(e); } finally { resume(tx); } }
public void destroy() throws CacheException { try { // NOTE : evict() operates locally only (i.e., does not propogate // to any other nodes in the potential cluster). This is // exactly what is needed when we destroy() here; destroy() is used // as part of the process of shutting down a SessionFactory; thus // these removals should not be propogated cache.evict(regionFqn); } catch (Exception e) { throw new CacheException(e); } }