diff options
author | Devtools Arcadia <arcadia-devtools@yandex-team.ru> | 2022-02-07 18:08:42 +0300 |
---|---|---|
committer | Devtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net> | 2022-02-07 18:08:42 +0300 |
commit | 1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch) | |
tree | e26c9fed0de5d9873cce7e00bc214573dc2195b7 /contrib/libs/poco/Foundation/include/Poco/ExpireLRUCache.h | |
download | ydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz |
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'contrib/libs/poco/Foundation/include/Poco/ExpireLRUCache.h')
-rw-r--r-- | contrib/libs/poco/Foundation/include/Poco/ExpireLRUCache.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/contrib/libs/poco/Foundation/include/Poco/ExpireLRUCache.h b/contrib/libs/poco/Foundation/include/Poco/ExpireLRUCache.h new file mode 100644 index 0000000000..d79281a8e8 --- /dev/null +++ b/contrib/libs/poco/Foundation/include/Poco/ExpireLRUCache.h @@ -0,0 +1,62 @@ +// +// ExpireLRUCache.h +// +// Library: Foundation +// Package: Cache +// Module: ExpireLRUCache +// +// Definition of the ExpireLRUCache class. +// +// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef Foundation_ExpireLRUCache_INCLUDED +#define Foundation_ExpireLRUCache_INCLUDED + + +#include "Poco/AbstractCache.h" +#include "Poco/StrategyCollection.h" +#include "Poco/ExpireStrategy.h" +#include "Poco/LRUStrategy.h" + + +namespace Poco { + + +template < + class TKey, + class TValue, + class TMutex = FastMutex, + class TEventMutex = FastMutex +> +class ExpireLRUCache: public AbstractCache<TKey, TValue, StrategyCollection<TKey, TValue>, TMutex, TEventMutex> + /// An ExpireLRUCache combines LRU caching and time based expire caching. + /// It cache entries for a fixed time period (per default 10 minutes) + /// but also limits the size of the cache (per default: 1024). +{ +public: + ExpireLRUCache(long cacheSize = 1024, Timestamp::TimeDiff expire = 600000): + AbstractCache<TKey, TValue, StrategyCollection<TKey, TValue>, TMutex, TEventMutex>(StrategyCollection<TKey, TValue>()) + { + this->_strategy.pushBack(new LRUStrategy<TKey, TValue>(cacheSize)); + this->_strategy.pushBack(new ExpireStrategy<TKey, TValue>(expire)); + } + + ~ExpireLRUCache() + { + } + +private: + ExpireLRUCache(const ExpireLRUCache& aCache); + ExpireLRUCache& operator = (const ExpireLRUCache& aCache); +}; + + +} // namespace Poco + + +#endif // Foundation_ExpireLRUCache_INCLUDED |