All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hazelcast.map.MapEvictionPolicyComparator Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2008-2024, Hazelcast, Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.hazelcast.map;

import com.hazelcast.config.MapConfig;
import com.hazelcast.core.EntryView;
import com.hazelcast.spi.eviction.EvictionPolicyComparator;

/**
 * {@link IMap} specific {@link EvictionPolicyComparator} for
 * comparing {@link com.hazelcast.core.EntryView}s to be evicted.
 * 

* Implementors of the comparator have to implement {@code equals} * and {@code hashCode} methods to support correct config comparison. *

* Note that you may need to enable per entry stats via * {@link MapConfig#setPerEntryStatsEnabled} to see * all fields of entry view in your implementation. * * @param type of the key * @param type of the value * @see EvictionPolicyComparator * @see EntryView * @see com.hazelcast.config.MapConfig#setPerEntryStatsEnabled */ @FunctionalInterface public interface MapEvictionPolicyComparator extends EvictionPolicyComparator> { /** * Compares the given {@link EntryView} instances and * returns the result. *

* The result should be one of: *

    *
  • -1: first entry has higher priority to be evicted
  • *
  • 1: second entry has higher priority to be evicted
  • *
  • 0: both entries have same priority
  • *
* * @param o1 the first {@link EntryView} instance to be compared * @param o2 the second {@link EntryView} instance to be compared * @return the result of comparison */ @Override int compare(EntryView o1, EntryView o2); }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy