changed getExpiration to getTimeout for Accesscaches

This commit is contained in:
Peter Schojer 2007-10-30 07:22:47 +00:00
parent 6987146b6c
commit 0a2cae61ff
4 changed files with 18 additions and 18 deletions

View File

@ -1,7 +1,7 @@
// //
// AccessExpirationDecorator.h // AccessExpirationDecorator.h
// //
// $Id: //poco/Main/Foundation/include/Poco/AccessExpirationDecorator.h#1 $ // $Id: //poco/Main/Foundation/include/Poco/AccessExpirationDecorator.h#2 $
// //
// Library: Foundation // Library: Foundation
// Package: Events // Package: Events
@ -55,21 +55,21 @@ class AccessExpirationDecorator
public: public:
AccessExpirationDecorator(): AccessExpirationDecorator():
_value(), _value(),
_expiresAt() _span()
{ {
} }
AccessExpirationDecorator(const TArgs& p, const Poco::Timespan::TimeDiff& diffInMs): AccessExpirationDecorator(const TArgs& p, const Poco::Timespan::TimeDiff& diffInMs):
/// Creates an element that will expire in diff milliseconds /// Creates an element that will expire in diff milliseconds
_value(p), _value(p),
_expiresAt(diffInMs*1000) _span(diffInMs*1000)
{ {
} }
AccessExpirationDecorator(const TArgs& p, const Poco::Timespan& timeSpan): AccessExpirationDecorator(const TArgs& p, const Poco::Timespan& timeSpan):
/// Creates an element that will expire after the given timeSpan /// Creates an element that will expire after the given timeSpan
_value(p), _value(p),
_expiresAt(timeSpan) _span(timeSpan)
{ {
} }
@ -78,9 +78,9 @@ public:
{ {
} }
const Poco::Timespan& getExpiration() const const Poco::Timespan& getTimeout() const
{ {
return _expiresAt; return _span;
} }
const TArgs& value() const const TArgs& value() const
@ -95,7 +95,7 @@ public:
private: private:
TArgs _value; TArgs _value;
Timespan _expiresAt; Timespan _span;
}; };

View File

@ -1,7 +1,7 @@
// //
// UniqueAccessExpireCache.h // UniqueAccessExpireCache.h
// //
// $Id$ // $Id: //poco/Main/Foundation/include/Poco/UniqueAccessExpireCache.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Cache // Package: Cache
@ -54,10 +54,10 @@ class UniqueAccessExpireCache: public AbstractCache<TKey, TValue, UniqueAccessEx
/// expiration per CacheEntry. /// expiration per CacheEntry.
/// Each TValue object must thus offer the following method: /// Each TValue object must thus offer the following method:
/// ///
/// const Poco::Timespan& getExpiration() const; /// const Poco::Timespan& getTimeout() const;
/// ///
/// which returns the relative timespan for how long the entry should be valid without being accessed! /// which returns the relative timespan for how long the entry should be valid without being accessed!
/// The absolute expire timepoint is calculated as now() + getExpiration(). /// The absolute expire timepoint is calculated as now() + getTimeout().
/// Accessing an object will update this absolute expire timepoint. /// Accessing an object will update this absolute expire timepoint.
/// You can use the Poco::AccessExpirationDecorator to add the getExpiration /// You can use the Poco::AccessExpirationDecorator to add the getExpiration
/// method to values that do not have a getExpiration function. /// method to values that do not have a getExpiration function.

View File

@ -1,7 +1,7 @@
// //
// UniqueAccessExpireLRUCache.h // UniqueAccessExpireLRUCache.h
// //
// $Id: //poco/Main/Foundation/include/Poco/UniqueAccessExpireLRUCache.h#1 $ // $Id: //poco/Main/Foundation/include/Poco/UniqueAccessExpireLRUCache.h#2 $
// //
// Library: Foundation // Library: Foundation
// Package: Cache // Package: Cache
@ -59,10 +59,10 @@ class UniqueAccessExpireLRUCache: public AbstractCache<TKey, TValue, StrategyCol
/// but also limit the size of the cache (per default: 1024). /// but also limit the size of the cache (per default: 1024).
/// Each TValue object must thus offer the following method: /// Each TValue object must thus offer the following method:
/// ///
/// const Poco::Timespan& getExpiration() const; /// const Poco::Timespan& getTimeout() const;
/// ///
/// which returns the relative timespan for how long the entry should be valid without being accessed! /// which returns the relative timespan for how long the entry should be valid without being accessed!
/// The absolute expire timepoint is calculated as now() + getExpiration(). /// The absolute expire timepoint is calculated as now() + getTimeout().
/// Accessing an object will update this absolute expire timepoint. /// Accessing an object will update this absolute expire timepoint.
/// You can use the Poco::AccessExpirationDecorator to add the getExpiration /// You can use the Poco::AccessExpirationDecorator to add the getExpiration
/// method to values that do not have a getExpiration function. /// method to values that do not have a getExpiration function.

View File

@ -1,7 +1,7 @@
// //
// UniqueAccessExpireStrategy.h // UniqueAccessExpireStrategy.h
// //
// $Id$ // $Id: //poco/Main/Foundation/include/Poco/UniqueAccessExpireStrategy.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Cache // Package: Cache
@ -66,9 +66,9 @@ class UniqueAccessExpireStrategy: public AbstractStrategy<TKey, TValue>
/// expiration per CacheEntry. /// expiration per CacheEntry.
/// Each TValue object must thus offer the following method: /// Each TValue object must thus offer the following method:
/// ///
/// const Poco::Timestamp& getExpiration() const; /// const Poco::Timestamp& getTimeout() const;
/// ///
/// which returns the absolute timepoint when the entry will be invalidated. /// which returns the timespan for how long an object will be valid without being accessed.
{ {
public: public:
typedef std::pair<TKey, Timespan> KeyExpire; typedef std::pair<TKey, Timespan> KeyExpire;
@ -93,9 +93,9 @@ public:
// the expire value defines how many millisecs in the future the // the expire value defines how many millisecs in the future the
// value will expire, even insert negative values! // value will expire, even insert negative values!
Timestamp expire; Timestamp expire;
expire += args.value().getExpiration().totalMicroseconds(); expire += args.value().getTimeout().totalMicroseconds();
IndexIterator it = _keyIndex.insert(std::make_pair(expire, std::make_pair(args.key(), args.value().getExpiration()))); IndexIterator it = _keyIndex.insert(std::make_pair(expire, std::make_pair(args.key(), args.value().getTimeout())));
std::pair<Iterator, bool> stat = _keys.insert(std::make_pair(args.key(), it)); std::pair<Iterator, bool> stat = _keys.insert(std::make_pair(args.key(), it));
if (!stat.second) if (!stat.second)
{ {