using namespace xmltooling;
using namespace std;
-ReplayCache::ReplayCache(StorageService* storage) : m_storage(storage)
+ReplayCache::ReplayCache(StorageService* storage) : m_owned(storage==NULL), m_storage(storage)
{
if (!m_storage)
m_storage = XMLToolingConfig::getConfig().StorageServiceManager.newPlugin(MEMORY_STORAGE_SERVICE, NULL);
ReplayCache::~ReplayCache()
{
- delete m_storage;
+ if (m_owned)
+ delete m_storage;
}
bool ReplayCache::check(const char* context, const char* s, time_t expires)
/**
* Creates a replay cache on top of a particular StorageService.
+ *
+ * The lifetime of the StorageService <strong>MUST</strong> be longer than
+ * the lifetime of the ReplayCache.
*
* @param storage pointer to a StorageService, or NULL to keep cache in memory
*/
}
private:
+ bool m_owned;
StorageService* m_storage;
};
};