@Test public void testPutIfAbsent() { assertEquals(testCache.get("putIfAbsent"), null); testCache.putIfAbsent(new Element("putIfAbsent", "1")); assertEquals(testCache.get("putIfAbsent").getValue(), "1"); testCache.putIfAbsent(new Element("putIfAbsent", "2")); assertEquals(testCache.get("putIfAbsent").getValue(), "1"); }
public boolean putIfAbsent(Element element) { try { acquireWriteLockOnKey(element.getKey()); if (!isKeyInCache(element.getKey())) { this.put(element); return true; } return false; } finally { releaseWriteLockOnKey(element.getKey()); } }
ExplicitLockingCache implements Ehcache { public boolean putIfAbsent(Element element) { try { acquireWriteLockOnKey(element.getKey()); if (!isKeyInCache(element.getKey())) { this.put(element); return true; } return false; } finally { releaseWriteLockOnKey(element.getKey()); } } }
ExplicitLockingCache implements Ehcache { public boolean putIfAbsent(Element element) { try { acquireWriteLockOnKey(element.getKey()); if (!isKeyInCache(element.getKey())) { this.put(element); return true; } return false; } finally { releaseWriteLockOnKey(element.getKey()); } } ExplicitLockingCache(Ehcache cache); }
ExplicitLockingCache implements Ehcache { public boolean putIfAbsent(Element element) { try { acquireWriteLockOnKey(element.getKey()); if (!isKeyInCache(element.getKey())) { this.put(element); return true; } return false; } finally { releaseWriteLockOnKey(element.getKey()); } } ExplicitLockingCache(Ehcache cache); String getName(); void setName(String name); boolean isExpired(Element element); @Override Object clone(); RegisteredEventListeners getCacheEventNotificationService(); boolean isElementInMemory(Serializable key); boolean isElementInMemory(Object key); boolean isElementOnDisk(Serializable key); boolean isElementOnDisk(Object key); String getGuid(); CacheManager getCacheManager(); void clearStatistics(); int getStatisticsAccuracy(); void setStatisticsAccuracy(int statisticsAccuracy); void evictExpiredElements(); boolean isKeyInCache(Object key); boolean isValueInCache(Object value); Statistics getStatistics(); LiveCacheStatistics getLiveCacheStatistics(); void setCacheManager(CacheManager cacheManager); BootstrapCacheLoader getBootstrapCacheLoader(); void setBootstrapCacheLoader(BootstrapCacheLoader bootstrapCacheLoader); void setDiskStorePath(String diskStorePath); void initialise(); void bootstrap(); void dispose(); CacheConfiguration getCacheConfiguration(); Element get(final Object key); void put(Element element); void put(Element element, boolean doNotNotifyCacheReplicators); void putQuiet(Element element); Element get(Serializable key); Element getQuiet(Serializable key); Element getQuiet(Object key); List getKeys(); List getKeysWithExpiryCheck(); List getKeysNoDuplicateCheck(); boolean remove(Serializable key); boolean remove(Object key); boolean remove(Serializable key, boolean doNotNotifyCacheReplicators); boolean remove(Object key, boolean doNotNotifyCacheReplicators); boolean removeQuiet(Serializable key); boolean removeQuiet(Object key); void removeAll(); void removeAll(boolean doNotNotifyCacheReplicators); void flush(); int getSize(); int getSizeBasedOnAccuracy(int statisticsAccuracy); long calculateInMemorySize(); long getMemoryStoreSize(); int getDiskStoreSize(); Status getStatus(); synchronized String liveness(); void registerCacheExtension(CacheExtension cacheExtension); void unregisterCacheExtension(CacheExtension cacheExtension); List<CacheExtension> getRegisteredCacheExtensions(); float getAverageGetTime(); void setCacheExceptionHandler(CacheExceptionHandler cacheExceptionHandler); CacheExceptionHandler getCacheExceptionHandler(); void registerCacheLoader(CacheLoader cacheLoader); void unregisterCacheLoader(CacheLoader cacheLoader); List<CacheLoader> getRegisteredCacheLoaders(); Element getWithLoader(Object key, CacheLoader loader, Object loaderArgument); Map getAllWithLoader(Collection keys, Object loaderArgument); void load(Object key); void loadAll(Collection keys, Object argument); boolean isDisabled(); void setDisabled(boolean disabled); void registerCacheUsageListener(CacheUsageListener cacheUsageListener); void removeCacheUsageListener(CacheUsageListener cacheUsageListener); boolean isStatisticsEnabled(); void setStatisticsEnabled(boolean enabledStatistics); SampledCacheStatistics getSampledCacheStatistics(); void setSampledStatisticsEnabled(boolean enabledStatistics); boolean isSampledStatisticsEnabled(); Object getInternalContext(); void acquireReadLockOnKey(Object key); void acquireWriteLockOnKey(Object key); void releaseReadLockOnKey(Object key); void releaseWriteLockOnKey(Object key); boolean tryReadLockOnKey(Object key, long timeout); boolean tryWriteLockOnKey(Object key, long timeout); boolean putIfAbsent(Element element); void disableDynamicFeatures(); void putWithWriter(Element element); boolean removeWithWriter(Object key); void registerCacheWriter(CacheWriter cacheWriter); void unregisterCacheWriter(); CacheWriter getRegisteredCacheWriter(); CacheWriterManager getWriterManager(); boolean isNodeCoherent(); boolean isClusterCoherent(); void setNodeCoherent(boolean coherent); void waitUntilClusterCoherent(); void setTransactionManagerLookup(
            TransactionManagerLookup transactionManagerLookup); }
ExplicitLockingCache implements Ehcache { public boolean putIfAbsent(Element element) { try { acquireWriteLockOnKey(element.getKey()); if (!isKeyInCache(element.getKey())) { this.put(element); return true; } return false; } finally { releaseWriteLockOnKey(element.getKey()); } } ExplicitLockingCache(Ehcache cache); String getName(); void setName(String name); boolean isExpired(Element element); @Override Object clone(); RegisteredEventListeners getCacheEventNotificationService(); boolean isElementInMemory(Serializable key); boolean isElementInMemory(Object key); boolean isElementOnDisk(Serializable key); boolean isElementOnDisk(Object key); String getGuid(); CacheManager getCacheManager(); void clearStatistics(); int getStatisticsAccuracy(); void setStatisticsAccuracy(int statisticsAccuracy); void evictExpiredElements(); boolean isKeyInCache(Object key); boolean isValueInCache(Object value); Statistics getStatistics(); LiveCacheStatistics getLiveCacheStatistics(); void setCacheManager(CacheManager cacheManager); BootstrapCacheLoader getBootstrapCacheLoader(); void setBootstrapCacheLoader(BootstrapCacheLoader bootstrapCacheLoader); void setDiskStorePath(String diskStorePath); void initialise(); void bootstrap(); void dispose(); CacheConfiguration getCacheConfiguration(); Element get(final Object key); void put(Element element); void put(Element element, boolean doNotNotifyCacheReplicators); void putQuiet(Element element); Element get(Serializable key); Element getQuiet(Serializable key); Element getQuiet(Object key); List getKeys(); List getKeysWithExpiryCheck(); List getKeysNoDuplicateCheck(); boolean remove(Serializable key); boolean remove(Object key); boolean remove(Serializable key, boolean doNotNotifyCacheReplicators); boolean remove(Object key, boolean doNotNotifyCacheReplicators); boolean removeQuiet(Serializable key); boolean removeQuiet(Object key); void removeAll(); void removeAll(boolean doNotNotifyCacheReplicators); void flush(); int getSize(); int getSizeBasedOnAccuracy(int statisticsAccuracy); long calculateInMemorySize(); long getMemoryStoreSize(); int getDiskStoreSize(); Status getStatus(); synchronized String liveness(); void registerCacheExtension(CacheExtension cacheExtension); void unregisterCacheExtension(CacheExtension cacheExtension); List<CacheExtension> getRegisteredCacheExtensions(); float getAverageGetTime(); void setCacheExceptionHandler(CacheExceptionHandler cacheExceptionHandler); CacheExceptionHandler getCacheExceptionHandler(); void registerCacheLoader(CacheLoader cacheLoader); void unregisterCacheLoader(CacheLoader cacheLoader); List<CacheLoader> getRegisteredCacheLoaders(); Element getWithLoader(Object key, CacheLoader loader, Object loaderArgument); Map getAllWithLoader(Collection keys, Object loaderArgument); void load(Object key); void loadAll(Collection keys, Object argument); boolean isDisabled(); void setDisabled(boolean disabled); void registerCacheUsageListener(CacheUsageListener cacheUsageListener); void removeCacheUsageListener(CacheUsageListener cacheUsageListener); boolean isStatisticsEnabled(); void setStatisticsEnabled(boolean enabledStatistics); SampledCacheStatistics getSampledCacheStatistics(); void setSampledStatisticsEnabled(boolean enabledStatistics); boolean isSampledStatisticsEnabled(); Object getInternalContext(); void acquireReadLockOnKey(Object key); void acquireWriteLockOnKey(Object key); void releaseReadLockOnKey(Object key); void releaseWriteLockOnKey(Object key); boolean tryReadLockOnKey(Object key, long timeout); boolean tryWriteLockOnKey(Object key, long timeout); boolean putIfAbsent(Element element); void disableDynamicFeatures(); void putWithWriter(Element element); boolean removeWithWriter(Object key); void registerCacheWriter(CacheWriter cacheWriter); void unregisterCacheWriter(); CacheWriter getRegisteredCacheWriter(); CacheWriterManager getWriterManager(); boolean isNodeCoherent(); boolean isClusterCoherent(); void setNodeCoherent(boolean coherent); void waitUntilClusterCoherent(); void setTransactionManagerLookup(
            TransactionManagerLookup transactionManagerLookup);  }