root / trunk / tbeta / OSX / libs / poco / include / Poco / ExpireCache.h @ 5
View | Annotate | Download (2.6 KB)
| 1 | 5 | ss | //
|
|---|---|---|---|
| 2 | 5 | ss | // ExpireCache.h
|
| 3 | 5 | ss | //
|
| 4 | 5 | ss | // $Id: //poco/1.3/Foundation/include/Poco/ExpireCache.h#1 $
|
| 5 | 5 | ss | //
|
| 6 | 5 | ss | // Library: Foundation
|
| 7 | 5 | ss | // Package: Cache
|
| 8 | 5 | ss | // Module: ExpireCache
|
| 9 | 5 | ss | //
|
| 10 | 5 | ss | // Definition of the ExpireCache class.
|
| 11 | 5 | ss | //
|
| 12 | 5 | ss | // Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
| 13 | 5 | ss | // and Contributors.
|
| 14 | 5 | ss | //
|
| 15 | 5 | ss | // Permission is hereby granted, free of charge, to any person or organization
|
| 16 | 5 | ss | // obtaining a copy of the software and accompanying documentation covered by
|
| 17 | 5 | ss | // this license (the "Software") to use, reproduce, display, distribute,
|
| 18 | 5 | ss | // execute, and transmit the Software, and to prepare derivative works of the
|
| 19 | 5 | ss | // Software, and to permit third-parties to whom the Software is furnished to
|
| 20 | 5 | ss | // do so, all subject to the following:
|
| 21 | 5 | ss | //
|
| 22 | 5 | ss | // The copyright notices in the Software and this entire statement, including
|
| 23 | 5 | ss | // the above license grant, this restriction and the following disclaimer,
|
| 24 | 5 | ss | // must be included in all copies of the Software, in whole or in part, and
|
| 25 | 5 | ss | // all derivative works of the Software, unless such copies or derivative
|
| 26 | 5 | ss | // works are solely in the form of machine-executable object code generated by
|
| 27 | 5 | ss | // a source language processor.
|
| 28 | 5 | ss | //
|
| 29 | 5 | ss | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 30 | 5 | ss | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 31 | 5 | ss | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
| 32 | 5 | ss | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
| 33 | 5 | ss | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
| 34 | 5 | ss | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
| 35 | 5 | ss | // DEALINGS IN THE SOFTWARE.
|
| 36 | 5 | ss | //
|
| 37 | 5 | ss | |
| 38 | 5 | ss | |
| 39 | 5 | ss | #ifndef Foundation_ExpireCache_INCLUDED
|
| 40 | 5 | ss | #define Foundation_ExpireCache_INCLUDED
|
| 41 | 5 | ss | |
| 42 | 5 | ss | |
| 43 | 5 | ss | #include "Poco/AbstractCache.h" |
| 44 | 5 | ss | #include "Poco/ExpireStrategy.h" |
| 45 | 5 | ss | |
| 46 | 5 | ss | |
| 47 | 5 | ss | namespace Poco {
|
| 48 | 5 | ss | |
| 49 | 5 | ss | |
| 50 | 5 | ss | template <class TKey, class TValue> |
| 51 | 5 | ss | class ExpireCache: public AbstractCache<TKey, TValue, ExpireStrategy<TKey, TValue> >
|
| 52 | 5 | ss | /// An ExpireCache caches entries for a fixed time period (per default 10 minutes)
|
| 53 | 5 | ss | /// Be careful when using an ExpireCache. A cache is often used
|
| 54 | 5 | ss | /// like cache.has(x) followed by cache.get x). Note that it could happen
|
| 55 | 5 | ss | /// that the "has" call works, then the current execution thread gets descheduled, time passes,
|
| 56 | 5 | ss | /// the entry gets invalid, thus leading to an empty SharedPtr being returned
|
| 57 | 5 | ss | /// when "get" is invoked.
|
| 58 | 5 | ss | {
|
| 59 | 5 | ss | public:
|
| 60 | 5 | ss | ExpireCache(Timestamp::TimeDiff expire = 600000):
|
| 61 | 5 | ss | AbstractCache<TKey, TValue, ExpireStrategy<TKey, TValue> >(ExpireStrategy<TKey, TValue>(expire)) |
| 62 | 5 | ss | {
|
| 63 | 5 | ss | } |
| 64 | 5 | ss | |
| 65 | 5 | ss | ~ExpireCache() |
| 66 | 5 | ss | {
|
| 67 | 5 | ss | } |
| 68 | 5 | ss | |
| 69 | 5 | ss | private:
|
| 70 | 5 | ss | ExpireCache(const ExpireCache& aCache);
|
| 71 | 5 | ss | ExpireCache& operator = (const ExpireCache& aCache);
|
| 72 | 5 | ss | }; |
| 73 | 5 | ss | |
| 74 | 5 | ss | |
| 75 | 5 | ss | } // namespace Poco
|
| 76 | 5 | ss | |
| 77 | 5 | ss | |
| 78 | 5 | ss | #endif |
