Oracle® Fusion Middleware C++ API Reference for Oracle Coherence
12c (12.1.3.0.0)

E47891-01

coherence/net/cache/EvictionPolicy.hpp

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