Oracle Coherence for C++ API
Release 3.7.0.0

E18684-01

coherence/net/NamedCache.hpp

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