@VisibleForTesting CacheManager() { CACHES = new CacheConnections(this); }
/** * Returns a {@link RevObject} cache * <p> * Multiple invocations of this method for the same key are guaranteed to return the same * {@link ObjectCache} as long as there's still at least one handle to the same cache, or a new * one otherwise. * * @param uniqueCacheIdentifier a client defined identifier for the objectcache */ public ObjectCache acquire(final String uniqueCacheIdentifier) { checkNotNull(uniqueCacheIdentifier); CacheIdentifier prefix = CACHE_IDS.get(uniqueCacheIdentifier); if (prefix == null) { prefix = new CacheIdentifier(CACHE_ID_SEQ.incrementAndGet()); CacheIdentifier existing = CACHE_IDS.putIfAbsent(uniqueCacheIdentifier, prefix); if (existing != null) { prefix = existing; } } return CACHES.acquire(prefix); }
/** * Returns a {@link RevObject} cache * <p> * Multiple invocations of this method for the same key are guaranteed to return the same * {@link ObjectCache} as long as there's still at least one handle to the same cache, or a new * one otherwise. * * @param uniqueCacheIdentifier a client defined identifier for the objectcache */ public ObjectCache acquire(final String uniqueCacheIdentifier) { checkNotNull(uniqueCacheIdentifier); CacheIdentifier prefix = CACHE_IDS.get(uniqueCacheIdentifier); if (prefix == null) { prefix = new CacheIdentifier(CACHE_ID_SEQ.incrementAndGet()); CacheIdentifier existing = CACHE_IDS.putIfAbsent(uniqueCacheIdentifier, prefix); if (existing != null) { prefix = existing; } } return CACHES.acquire(prefix); }
@VisibleForTesting CacheManager() { CACHES = new CacheConnections(this); }
/** * Indicates the client code that obtained the {@link ObjectCache} through the {@link #acquire} * method does no longer need it and hence the cache manager is free to release the object cache * if there are no more clients for it. * * @param cache the cache to return to the pool. */ public void release(ObjectCache cache) { CACHES.release(cache); }
/** * Indicates the client code that obtained the {@link ObjectCache} through the {@link #acquire} * method does no longer need it and hence the cache manager is free to release the object cache * if there are no more clients for it. * * @param cache the cache to return to the pool. */ public void release(ObjectCache cache) { CACHES.release(cache); }