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            @Id
040            public String getName();
041    
042            public PortalCacheManager<K, V> getPortalCacheManager();
043    
044            @Proxy
045            public void put(K key, V value);
046    
047            @Proxy
048            public void put(K key, V value, int timeToLive);
049    
050            public void registerCacheListener(CacheListener<K, V> cacheListener);
051    
052            public void registerCacheListener(
053                    CacheListener<K, V> cacheListener,
054                    CacheListenerScope cacheListenerScope);
055    
056            @Proxy
057            public void remove(K key);
058    
059            @Proxy
060            public void removeAll();
061    
062            public void unregisterCacheListener(CacheListener<K, V> cacheListener);
063    
064            public void unregisterCacheListeners();
065    
066    }