001
014
015 package com.liferay.portal.kernel.cache;
016
017 import java.io.Serializable;
018
019
022 public class PortalCacheHelperUtil {
023
024 public static <K extends Serializable, V> void putWithoutReplicator(
025 PortalCache<K, V> portalCache, K key, V value) {
026
027 putWithoutReplicator(
028 portalCache, key, value, PortalCache.DEFAULT_TIME_TO_LIVE);
029 }
030
031 public static <K extends Serializable, V> void putWithoutReplicator(
032 PortalCache<K, V> portalCache, K key, V value, int timeToLive) {
033
034 boolean remoteInvoke = AggregatedCacheListener.isRemoteInvoke();
035
036 if (!remoteInvoke) {
037 AggregatedCacheListener.setRemoteInvoke(true);
038 }
039
040 try {
041 portalCache.put(key, value, timeToLive);
042 }
043 finally {
044 if (!remoteInvoke) {
045 AggregatedCacheListener.setRemoteInvoke(false);
046 }
047 }
048 }
049
050 public static void removeAllWithoutReplicator(
051 PortalCache<?, ?> portalCache) {
052
053 boolean remoteInvoke = AggregatedCacheListener.isRemoteInvoke();
054
055 if (!remoteInvoke) {
056 AggregatedCacheListener.setRemoteInvoke(true);
057 }
058
059 try {
060 portalCache.removeAll();
061 }
062 finally {
063 if (!remoteInvoke) {
064 AggregatedCacheListener.setRemoteInvoke(false);
065 }
066 }
067 }
068
069 public static <K extends Serializable> void removeWithoutReplicator(
070 PortalCache<K, ?> portalCache, K key) {
071
072 boolean remoteInvoke = AggregatedCacheListener.isRemoteInvoke();
073
074 if (!remoteInvoke) {
075 AggregatedCacheListener.setRemoteInvoke(true);
076 }
077
078 try {
079 portalCache.remove(key);
080 }
081 finally {
082 if (!remoteInvoke) {
083 AggregatedCacheListener.setRemoteInvoke(false);
084 }
085 }
086 }
087
088 }