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         */
036        V lookup(K key);
037
038        /**
039         * Return the maximum cache Size.
040         *
041         * @return the maximum cache size.
042         */
043        int getMaxCacheSize();
044
045        /**
046         * Set the maximum cache size.
047         * @param size the new maximum cache size.
048         */
049        void setMaxCacheSize(int size);
050}