001/**
002 *
003 * Copyright © 2014-2018 Florian Schmaus
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.jxmpp.util.cache;
018
019public interface Cache<K, V> {
020
021        /**
022         * Put a value in the cache.
023         *
024         * @param key the key of the value.
025         * @param value the value.
026         * @return the previous value or {@code null}.
027         */
028        V put(K key, V value);
029
030        /**
031         * Returns the value of the specified key, or {@code null}.
032         *
033         * @param key the key.
034         * @return the value found in the cache, or {@code null}.
035         * @deprecated Use {@link #lookup(Object)} instead.
036         */
037        @Deprecated
038        V get(Object key);
039
040        /**
041         * Returns the value of the specified key, or {@code null}.
042         *
043         * @param key the key.
044         * @return the value found in the cache, or {@code null}.
045         */
046        V lookup(K key);
047
048        /**
049         * Return the maximum cache Size.
050         *
051         * @return the maximum cache size.
052         */
053        int getMaxCacheSize();
054
055        /**
056         * Set the maximum cache size.
057         * @param size the new maximum cache size.
058         */
059        void setMaxCacheSize(int size);
060}