1//
2// ExpireLRUCache.h
3//
4// Library: Foundation
5// Package: Cache
6// Module: ExpireLRUCache
7//
8// Definition of the ExpireLRUCache 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_ExpireLRUCache_INCLUDED
18#define Foundation_ExpireLRUCache_INCLUDED
19
20
21#include "Poco/AbstractCache.h"
22#include "Poco/StrategyCollection.h"
23#include "Poco/ExpireStrategy.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 ExpireLRUCache: public AbstractCache<TKey, TValue, StrategyCollection<TKey, TValue>, TMutex, TEventMutex>
37 /// An ExpireLRUCache 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 ExpireLRUCache(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 ExpireStrategy<TKey, TValue>(expire));
47 }
48
49 ~ExpireLRUCache()
50 {
51 }
52
53private:
54 ExpireLRUCache(const ExpireLRUCache& aCache);
55 ExpireLRUCache& operator = (const ExpireLRUCache& aCache);
56};
57
58
59} // namespace Poco
60
61
62#endif // Foundation_ExpireLRUCache_INCLUDED
63