AccessExpireLRUCache.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. #ifndef Foundation_AccessExpireLRUCache_INCLUDED
  16. #define Foundation_AccessExpireLRUCache_INCLUDED
  17. #include "Poco/AbstractCache.h"
  18. #include "Poco/StrategyCollection.h"
  19. #include "Poco/AccessExpireStrategy.h"
  20. #include "Poco/LRUStrategy.h"
  21. namespace Poco {
  22. template <
  23. class TKey,
  24. class TValue,
  25. class TMutex = FastMutex,
  26. class TEventMutex = FastMutex
  27. >
  28. class AccessExpireLRUCache: public AbstractCache<TKey, TValue, StrategyCollection<TKey, TValue>, TMutex, TEventMutex>
  29. /// An AccessExpireLRUCache combines LRU caching and time based expire caching.
  30. /// It cache entries for a fixed time period (per default 10 minutes)
  31. /// but also limits the size of the cache (per default: 1024).
  32. {
  33. public:
  34. AccessExpireLRUCache(long cacheSize = 1024, Timestamp::TimeDiff expire = 600000):
  35. AbstractCache<TKey, TValue, StrategyCollection<TKey, TValue>, TMutex, TEventMutex >(StrategyCollection<TKey, TValue>())
  36. {
  37. this->_strategy.pushBack(new LRUStrategy<TKey, TValue>(cacheSize));
  38. this->_strategy.pushBack(new AccessExpireStrategy<TKey, TValue>(expire));
  39. }
  40. ~AccessExpireLRUCache()
  41. {
  42. }
  43. private:
  44. AccessExpireLRUCache(const AccessExpireLRUCache& aCache);
  45. AccessExpireLRUCache& operator = (const AccessExpireLRUCache& aCache);
  46. };
  47. } // namespace Poco
  48. #endif // Foundation_AccessExpireLRUCache_INCLUDED