11d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert/* 21d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * Copyright (C) 2011 The Guava Authors 31d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * 41d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * Licensed under the Apache License, Version 2.0 (the "License"); 51d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * you may not use this file except in compliance with the License. 61d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * You may obtain a copy of the License at 71d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * 81d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * http://www.apache.org/licenses/LICENSE-2.0 91d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * 101d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * Unless required by applicable law or agreed to in writing, software 111d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * distributed under the License is distributed on an "AS IS" BASIS, 121d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 131d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * See the License for the specific language governing permissions and 141d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * limitations under the License. 151d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert */ 161d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert 171d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringertpackage com.google.common.cache; 181d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert 191d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringertimport com.google.common.annotations.Beta; 207dd252788645e940eada959bdde927426e2531c9Paul Duffinimport com.google.common.annotations.GwtCompatible; 211d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert 221d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert/** 231d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * An object that can receive a notification when an entry is removed from a cache. The removal 241d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * resulting in notification could have occured to an entry being manually removed or replaced, or 251d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * due to eviction resulting from timed expiration, exceeding a maximum size, or garbage 261d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * collection. 271d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * 281d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * <p>An instance may be called concurrently by multiple threads to process different entries. 291d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * Implementations of this interface should avoid performing blocking calls or synchronizing on 301d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * shared resources. 311d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * 321d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * @param <K> the most general type of keys this listener can listen for; for 331d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * example {@code Object} if any key is acceptable 341d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * @param <V> the most general type of values this listener can listen for; for 351d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * example {@code Object} if any key is acceptable 361d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * @author Charles Fry 371d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * @since 10.0 381d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert */ 391d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert@Beta 407dd252788645e940eada959bdde927426e2531c9Paul Duffin@GwtCompatible 411d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringertpublic interface RemovalListener<K, V> { 421d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert /** 431d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * Notifies the listener that a removal occurred at some point in the past. 441d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert */ 451d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert // Technically should accept RemovalNotification<? extends K, ? extends V>, but because 461d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert // RemovalNotification is guaranteed covariant, let's make users' lives simpler. 471d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert void onRemoval(RemovalNotification<K, V> notification); 481d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert} 49