001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.cache;
016    
017    import com.liferay.portal.kernel.nio.intraband.proxy.annotation.Id;
018    import com.liferay.portal.kernel.nio.intraband.proxy.annotation.Proxy;
019    
020    import java.io.Serializable;
021    
022    import java.util.List;
023    
024    /**
025     * @author Brian Wing Shun Chan
026     * @author Edward Han
027     * @author Shuyang Zhou
028     */
029    public interface PortalCache<K extends Serializable, V> {
030    
031            public static final int DEFAULT_TIME_TO_LIVE = 0;
032    
033            @Proxy
034            public V get(K key);
035    
036            @Proxy
037            public List<K> getKeys();
038    
039            /**
040             * @deprecated As of 7.0.0, replaced by {@link #getPortalCacheName()}
041             */
042            @Deprecated
043            @Id
044            public String getName();
045    
046            public PortalCacheManager<K, V> getPortalCacheManager();
047    
048            @Id
049            public String getPortalCacheName();
050    
051            @Proxy
052            public void put(K key, V value);
053    
054            @Proxy
055            public void put(K key, V value, int timeToLive);
056    
057            public void registerPortalCacheListener(
058                    PortalCacheListener<K, V> portalCacheListener);
059    
060            public void registerPortalCacheListener(
061                    PortalCacheListener<K, V> portalCacheListener,
062                    PortalCacheListenerScope portalCacheListenerScope);
063    
064            @Proxy
065            public void remove(K key);
066    
067            @Proxy
068            public void removeAll();
069    
070            public void unregisterPortalCacheListener(
071                    PortalCacheListener<K, V> portalCacheListener);
072    
073            public void unregisterPortalCacheListeners();
074    
075    }