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

E90870-01

coherence/net/NamedCache.hpp

00001 /*
00002 * NamedCache.hpp
00003 *
00004 * Copyright (c) 2000, 2019, 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_NAMED_CACHE_HPP
00017 #define COH_NAMED_CACHE_HPP
00018 
00019 #include "coherence/lang.ns"
00020 
00021 #include "coherence/net/ViewBuilder.hpp"
00022 
00023 #include "coherence/net/cache/CacheMap.hpp"
00024 
00025 #include "coherence/util/ConcurrentMap.hpp"
00026 #include "coherence/util/InvocableMap.hpp"
00027 #include "coherence/util/ObservableMap.hpp"
00028 #include "coherence/util/QueryMap.hpp"
00029 
00030 COH_OPEN_NAMESPACE2(coherence,net)
00031 
00032 using coherence::net::cache::CacheMap;
00033 using coherence::util::ConcurrentMap;
00034 using coherence::util::InvocableMap;
00035 using coherence::util::ObservableMap;
00036 using coherence::util::QueryMap;
00037 
00038 class CacheService;
00039 
00040 /**
00041 * A NamedCache is a Map that holds resources shared among members of a
00042 * cluster. These resources are expected to be managed in memory, and are
00043 * typically composed of data that are also stored persistently in a database,
00044 * or data that have been assembled or calculated at some significant cost,
00045 * thus these resources are referred to as <i>cached</i>.
00046 *
00047 * @see coherence::net::cache::CacheMap
00048 * @see coherence::util::ConcurrentMap
00049 * @see coherence::util::InvocableMap
00050 * @see coherence::util::ObservableMap
00051 * @see coherence::util::QueryMap
00052 *
00053 * @author jh  2008.03.05
00054 */
00055 class COH_EXPORT NamedCache
00056     : public interface_spec<NamedCache,
00057         implements<CacheMap, ConcurrentMap, InvocableMap, QueryMap,
00058                    ObservableMap> >
00059     {
00060     // ----- handle definitions ---------------------------------------------
00061 
00062     public:
00063         /**
00064         * CacheService Handle definition.
00065         */
00066         typedef TypedHandle<CacheService> CacheServiceHandle;
00067 
00068         /**
00069         * CacheService View definition.
00070         */
00071         typedef TypedHandle<const CacheService> CacheServiceView;
00072 
00073 
00074     // ----- NamedCache interface -------------------------------------------
00075 
00076     public:
00077         /**
00078         * Return the cache name.
00079         *
00080         * @return the cache name
00081         */
00082         virtual String::View getCacheName() const = 0;
00083 
00084         /**
00085         * Return the CacheService that this NamedCache is a part of.
00086         *
00087         * @return the CacheService
00088         */
00089         virtual CacheServiceHandle getCacheService() = 0;
00090 
00091         /**
00092         * Return the CacheService that this NamedCache is a part of.
00093         *
00094         * @return the CacheService
00095         */
00096         virtual CacheServiceView getCacheService() const = 0;
00097 
00098         /**
00099         * Specifies whether or not the NamedCache is active.
00100         *
00101         * @return true if the NamedCache is active; false otherwise
00102         */
00103         virtual bool isActive() const = 0;
00104 
00105         /**
00106         * Release local resources associated with this instance of
00107         * NamedCache.
00108         *
00109         * Releasing a cache makes it no longer usable, but does not affect
00110         * the cache itself. In other words, all other references to the cache
00111         * will still be valid, and the cache data is not affected by
00112         * releasing the reference. Any attempt to use this reference
00113         * afterward will result in an exception.
00114         *
00115         * Caches should be released by the same mechanism in which they were
00116         * obtained. For example:
00117         * <ul>
00118         *  <li> Cache::create() - cache->release()</li>
00119         *  <li> CacheFactory::getCache() - CacheFactory::releaseCache()</li>
00120         *  <li> ConfigurableCacheFactory::ensureCache() - ConfigurableCacheFactory::releaseCache()</li>
00121         * </ul>
00122         * Except for the case where the application code explicitly allocated
00123         * the cache, this method should not be called by application code.
00124         *
00125         * @see CacheFactory#releaseCache
00126         * @see ConfigurableCacheFactory#releaseCache
00127         */
00128         virtual void release() = 0;
00129 
00130         /**
00131         * Release and destroy this instance of NamedCache.
00132         *
00133         * <b>Warning:</b> This method is used to completely destroy the
00134         * specified cache across the cluster. All references in the entire
00135         * cluster to this cache will be invalidated, the cached data will be
00136         * cleared, and all resources will be released.
00137         *
00138         * Caches should be destroyed by the same mechanism in which they were
00139         * obtained. For example:
00140         * <ul>
00141         *  <li> Cache::create() - cache->destroy()</li>
00142         *  <li> CacheFactory::getCache() - CacheFactory::destroyCache()</li>
00143         *  <li> ConfigurableCacheFactory::ensureCache() - ConfigurableCacheFactory::destroyCache()</li>
00144         * </ul>
00145         * Except for the case where the application code explicitly allocated
00146         * the cache, this method should not be called by application code.
00147         *
00148         * @see CacheService#destroyCache
00149         */
00150         virtual void destroy() = 0;
00151 
00152         /**
00153         * Removes all mappings from this map.
00154         * <p>
00155         * Note: the removal of entries caused by this truncate operation will
00156         * not be observable. This includes any registered {@link MapListener
00157         * listeners}, {@link MapTrigger triggers}, or interceptors. However, a
00158         * CacheLifecycleEvent is raised to notify subscribers of the execution
00159         * of this operation.
00160         *
00161         * @throws UnsupportedOperationException if the server does not support the truncate operation
00162         */
00163         virtual void truncate()
00164             {
00165             COH_THROW (UnsupportedOperationException::create());
00166             }
00167 
00168         /**
00169         * Construct a view of this NamedCache.
00170         *
00171         * @return a local view for this NamedCache
00172         *
00173         * @see ViewBuilder
00174         *
00175         * @since 12.2.1.4
00176         */
00177         virtual ViewBuilder::Handle view()
00178             {
00179             return ViewBuilder::create(this);
00180             }
00181     };
00182 
00183 COH_CLOSE_NAMESPACE2
00184 
00185 #endif // COH_NAMED_CACHE_HPP
Copyright © 2000, 2019, Oracle and/or its affiliates. All rights reserved.