1//
2// AccessExpireLRUCache.h
3//
4// Library: Foundation
5// Package: Cache
6// Module: AccessExpireLRUCache
7//
8// Definition of the AccessExpireLRUCache class.
9//
10// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
11// and Contributors.
12//
13// SPDX-License-Identifier: BSL-1.0
14//
15
16
17#ifndef Foundation_AccessExpireLRUCache_INCLUDED
18#define Foundation_AccessExpireLRUCache_INCLUDED
19
20
21#include "Poco/AbstractCache.h"
22#include "Poco/StrategyCollection.h"
23#include "Poco/AccessExpireStrategy.h"
24#include "Poco/LRUStrategy.h"
25
26
27namespace Poco {
28
29
30template <
31 class TKey,
32 class TValue,
33 class TMutex = FastMutex,
34 class TEventMutex = FastMutex
35>
36class AccessExpireLRUCache: public AbstractCache<TKey, TValue, StrategyCollection<TKey, TValue>, TMutex, TEventMutex>
37 /// An AccessExpireLRUCache combines LRU caching and time based expire caching.
38 /// It cache entries for a fixed time period (per default 10 minutes)
39 /// but also limits the size of the cache (per default: 1024).
40{
41public:
42 AccessExpireLRUCache(std::size_t cacheSize = 1024, Timestamp::TimeDiff expire = 600000):
43 AbstractCache<TKey, TValue, StrategyCollection<TKey, TValue>, TMutex, TEventMutex >(StrategyCollection<TKey, TValue>())
44 {
45 this->_strategy.pushBack(new LRUStrategy<TKey, TValue>(cacheSize));
46 this->_strategy.pushBack(new AccessExpireStrategy<TKey, TValue>(expire));
47 }
48
49 ~AccessExpireLRUCache()
50 {
51 }
52
53private:
54 AccessExpireLRUCache(const AccessExpireLRUCache& aCache);
55 AccessExpireLRUCache& operator = (const AccessExpireLRUCache& aCache);
56};
57
58
59} // namespace Poco
60
61
62#endif // Foundation_AccessExpireLRUCache_INCLUDED
63