C++ Client API Reference for Oracle Coherence
14c (14.1.2.0.0)

F79659-03

coherence/net/cache/EvictionPolicy.hpp

00001 /*
00002  * Copyright (c) 2000, 2020, Oracle and/or its affiliates.
00003  *
00004  * Licensed under the Universal Permissive License v 1.0 as shown at
00005  * http://oss.oracle.com/licenses/upl.
00006  */
00007 #ifndef COH_EVICTION_POLICY_HPP
00008 #define COH_EVICTION_POLICY_HPP
00009 
00010 #include "coherence/lang.ns"
00011 
00012 #include "coherence/util/Map.hpp"
00013 
00014 COH_OPEN_NAMESPACE3(coherence,net,cache)
00015 
00016 using coherence::util::Map;
00017 
00018 
00019 /**
00020 * An eviction policy is an object that the cache provides with access
00021 * information, and when requested, the eviction policy selects and
00022 * evicts entries from the cache. If the eviction policy needs to be
00023 * aware of changes to the cache, it must implement the MapListener
00024 * interface; if it does, it will automatically be registered to receive
00025 * MapEvents.
00026 *
00027 * @author nsa 2008.06.23
00028 */
00029 class EvictionPolicy
00030     : public interface_spec<EvictionPolicy>
00031     {
00032     // ----- constants ------------------------------------------------------
00033 
00034     public:
00035         /**
00036         * EvictionPolicyType describes the eviction policies available
00037         */
00038         typedef enum
00039             {
00040             /**
00041             * By default, the cache prunes based on a hybrid LRU+LFU
00042             * algorithm.
00043             */
00044             eviction_policy_hybrid   = 0,
00045             /**
00046             * The cache can prune based on a pure Least Recently Used (LRU)
00047             * algorithm.
00048             */
00049             eviction_policy_lru      = 1,
00050             /**
00051             * The cache can prune based on a pure Least Frequently Used (LFU)
00052             * algorithm.
00053             */
00054             eviction_policy_lfu      = 2,
00055             /**
00056             * The cache can prune using an external eviction policy.
00057             */
00058             eviction_policy_external = 3
00059             } EvictionPolicyType;
00060 
00061     // ----- EvictionPolicy interface ---------------------------------------
00062 
00063     public:
00064         /**
00065         * This method is called by the cache to indicate that an entry has
00066         * been touched.
00067         *
00068         * @param hEntry  the Cache Entry that has been touched
00069         */
00070         virtual void entryTouched(Map::Entry::Handle hEntry) = 0; // TODO NSA - Have Mark Review
00071 
00072         /**
00073         * This method is called by the cache when the cache requires the
00074         * eviction policy to evict entries.
00075         *
00076         * @param cMaximum  the maximum number of units that should remain
00077         *                  in the cache when the eviction is complete
00078         */
00079         virtual void requestEviction(int32_t cMaximum) = 0;
00080     };
00081 
00082 COH_CLOSE_NAMESPACE3
00083 
00084 #endif // #define COH_EVICTION_POLICY_HPP
Copyright © 2000, 2025, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.