AccessExpireLRUCache.h 1.6 KB

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