org.codehaus.cake.cache.policy.paging.MFUReplacementPolicy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cake-cache-api Show documentation
Show all versions of cake-cache-api Show documentation
This library contains class that are used across all Cake projects
The newest version!
/*
* Copyright 2008 Kasper Nielsen.
*
* 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://cake.codehaus.org/LICENSE
*
* 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 org.codehaus.cake.cache.policy.paging;
import static org.codehaus.cake.cache.CacheEntry.HITS;
import org.codehaus.cake.cache.CacheEntry;
import org.codehaus.cake.cache.policy.spi.AbstractHeapReplacementPolicy;
/**
* Not widely used. See, for example, http://citeseer.ist.psu.edu/mekhiel95multilevel.html
*
* @param
* the type of keys maintained by the cache
* @param
* the type of values maintained by the cache
*/
public class MFUReplacementPolicy extends AbstractHeapReplacementPolicy {
/** A unique policy name. */
public static final String NAME = "MFU";
public MFUReplacementPolicy() {
// This is used to make sure that the cache will lazy register the HITS attribute
// if the user has not already done so using CacheAttributeConfiguration#add(Attribute...)}
dependSoft(HITS);
}
@Override
protected int compareEntry(CacheEntry o1, CacheEntry o2) {
return -HITS.compare(o1, o2);
}
@Override
public void touch(CacheEntry entry) {
siftUp(entry);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy