Interface CacheInterceptor<K,V>
- 
- All Superinterfaces:
- Serializable
 - All Known Implementing Classes:
- CacheInterceptorAdapter
 
 public interface CacheInterceptor<K,V> extends Serializable Cache interceptor. Cache interceptor can be used for getting callbacks before and after cacheget(...),put(...), andremove(...)operations. TheonBeforecallbacks can also be used to change the values stored in cache or preventing entries from being removed from cache.Cache interceptor is configured via CacheConfiguration.getInterceptor()configuration property.Any grid resource from org.apache.ignite.resourcespackage can be injected into implementation of this interface.
- 
- 
Method SummaryAll Methods Instance Methods Abstract Methods Modifier and Type Method Description voidonAfterPut(javax.cache.Cache.Entry<K,V> entry)This method is called after new value has been stored.voidonAfterRemove(javax.cache.Cache.Entry<K,V> entry)This method is called after value has been removed.VonBeforePut(javax.cache.Cache.Entry<K,V> entry, V newVal)This method is called withinIgniteCache.put(Object, Object)and similar operations before new value is stored in cache.@Nullable IgniteBiTuple<Boolean,V>onBeforeRemove(javax.cache.Cache.Entry<K,V> entry)This method is called withinIgniteCache.remove(Object)and similar operations to provide control over returned value.VonGet(K key, V val)This method is called withinIgniteCache.get(Object)and similar operations to provide control over returned value.
 
- 
- 
- 
Method Detail- 
onGet@Nullable V onGet(K key, @Nullable V val) This method is called withinIgniteCache.get(Object)and similar operations to provide control over returned value.If this method returns null, thenget()operation results innullas well.This method should not throw any exception. - Parameters:
- key- Key.
- val- Value mapped to- keyat the moment of- get()operation.
- Returns:
- The new value to be returned as result of get()operation.
- See Also:
- Cache.get(Object)
 
 - 
onBeforePut@Nullable V onBeforePut(javax.cache.Cache.Entry<K,V> entry, V newVal) This method is called withinIgniteCache.put(Object, Object)and similar operations before new value is stored in cache.Implementations should not execute any complex logic, including locking, networking or cache operations, as it may lead to deadlock, since this method is called from sensitive synchronization blocks. This method should not throw any exception. IMPORTANT: for this method to take affect, newValand the returned value have to be different instances. I.e., you should not mutatenewValdirectly, but instead create a copy, update it and then return from the interceptor.- Parameters:
- entry- Old entry. If- CacheConfiguration.isCopyOnRead()is- true, then is copy.
- newVal- New value.
- Returns:
- Value to be put to cache. Returning nullcancels the update.
- See Also:
- IgniteCache.put(Object, Object)
 
 - 
onAfterPutvoid onAfterPut(javax.cache.Cache.Entry<K,V> entry) This method is called after new value has been stored.Implementations should not execute any complex logic, including locking, networking or cache operations, as it may lead to deadlock, since this method is called from sensitive synchronization blocks. This method should not throw any exception. - Parameters:
- entry- Current entry. If- CacheConfiguration.isCopyOnRead()is- truethen entry is a copy.
 
 - 
onBeforeRemove@Nullable @Nullable IgniteBiTuple<Boolean,V> onBeforeRemove(javax.cache.Cache.Entry<K,V> entry) This method is called withinIgniteCache.remove(Object)and similar operations to provide control over returned value.Implementations should not execute any complex logic, including locking, networking or cache operations, as it may lead to deadlock, since this method is called from sensitive synchronization blocks. This method should not throw any exception. - Parameters:
- entry- Old entry. If- CacheConfiguration.isCopyOnRead()is- truethen entry is a copy.
- Returns:
- Tuple. The first value is the flag whether remove should be cancelled or not.
      The second is the value to be returned as result of remove()operation, may benull.
- See Also:
- IgniteCache.remove(Object)
 
 - 
onAfterRemovevoid onAfterRemove(javax.cache.Cache.Entry<K,V> entry) This method is called after value has been removed.Implementations should not execute any complex logic, including locking, networking or cache operations, as it may lead to deadlock, since this method is called from sensitive synchronization blocks. This method should not throw any exception. - Parameters:
- entry- Removed entry. If- CacheConfiguration.isCopyOnRead()is- truethen entry is a copy.
 
 
- 
 
-