* Puts a collection of elements in the cache. Throws a NullPointerException if any element in the
106
* collection is null. Also notifies the CacheEventListener that:
107
* <ul>
108
* <li>the elements were put. The puts{@link net.sf.ehcache.Ehcache#put(net.sf.ehcache.Element)} happen in batches and the notifications are thrown for every put in the
109
* batch irrespective of whether the element is present in the cache or not i.e this method consider
110
* each element as new entry.
111
* </li>
112
* </ul>
113
* This operation is partially completed if any element or any key is null
114
* @param elements a collection of elements to be put in the cache.
115
* If elements are Serializable it can fully participate in replication and the DiskStore.
116
* @throws IllegalStateException if the cache is not {@link net.sf.ehcache.Status#STATUS_ALIVE}
107
* Puts a collection of elements in to the cache.
108
* <p>
109
* This method will throw a {@code NullPointerException} if a null element or null key is encountered
110
* in the collection, and a partial completion may result (as only some of the elements may have been put).
111
* <p>
112
* For each element that is put the registered {@code CacheEventListener}s are notified of a newly put item
Element putIfAbsent(Element element) throws NullPointerException;
186
187
187
188
/**
189
* Put an element in the cache if no element is currently mapped to the elements key.
190
*
191
* @param element element to be added
192
* @param doNotNotifyCacheReplicators whether the put is coming from a doNotNotifyCacheReplicators cache peer, in which case this put should not initiate a
193
* further notification to doNotNotifyCacheReplicators cache peers
194
* @return the element previously cached for this key, or null if none.
195
*
196
* @throws NullPointerException if the element is null, or has a null key
197
*/
198
Element putIfAbsent(Element element, boolean doNotNotifyCacheReplicators) throws NullPointerException;
199
200
/**
188
201
* Remove the Element mapped to the key for the supplied element if the value of the supplied Element
189
202
* is equal to the value of the cached Element.
190
203
*
198
211
/**
199
212
* Replace the cached element only if the current Element is equal to the supplied old Element.
200
213
*
214
* With eventual consistency two simultaneous replace operations in different nodes (or threads) can return true.
215
* But at the Terracotta Server Array, only one of the operations is allowed to succeed and all competing values are invalidated,
216
* eventually making the caches consistent in all nodes.
217
*
201
218
* @param old Element to be test against
202
219
* @param element Element to be cached
203
* @return true is the Element was replaced
220
* @return true if the Element was replaced
204
221
* @throws NullPointerException if the either Element is null or has a null key
205
222
* @throws IllegalArgumentException if the two Element keys are non-null but not equal
206
223
*/
242
259
Element get(Object key) throws IllegalStateException, CacheException;
243
260
244
261
/**
245
* Gets all the elements from the cache for the keys provided. Updates Element Statistics
262
* Gets all the elements from the cache for the keys provided. Updates Element Statistics.
263
* Returned Map may contain less or more keys if collection is modified before call completes.
246
264
* Throws a NullPointerException if any key in the collection is null
247
265
* <p/>
248
266
* Note that the Element's lastAccessTime is always the time of this get.
860
878
861
879
862
880
/**
863
* DiskStore paths can conflict between CacheManager instances. This method allows the path to be changed.
864
*
865
* @param diskStorePath the new path to be used.
866
* @throws CacheException if this method is called after the cache is initialized