*/
#include "internal.h"
+#include "logging.h"
#include "util/NDC.h"
#include "util/StorageService.h"
#include "util/Threads.h"
#include "util/XMLHelper.h"
-#include <log4cpp/Category.hh>
#include <xercesc/util/XMLUniDefs.hpp>
+using namespace xmltooling::logging;
using namespace xmltooling;
-using namespace log4cpp;
using namespace std;
namespace xmltooling {
MemoryStorageService(const DOMElement* e);
virtual ~MemoryStorageService();
- void createString(const char* context, const char* key, const char* value, time_t expiration);
+ bool createString(const char* context, const char* key, const char* value, time_t expiration);
int readString(const char* context, const char* key, string* pvalue=NULL, time_t* pexpiration=NULL, int version=0);
int updateString(const char* context, const char* key, const char* value=NULL, time_t expiration=0, int version=0);
bool deleteString(const char* context, const char* key);
- void createText(const char* context, const char* key, const char* value, time_t expiration) {
+ bool createText(const char* context, const char* key, const char* value, time_t expiration) {
return createString(context, key, value, expiration);
}
int readText(const char* context, const char* key, string* pvalue=NULL, time_t* pexpiration=NULL, int version=0) {
return count;
}
-void MemoryStorageService::createString(const char* context, const char* key, const char* value, time_t expiration)
+bool MemoryStorageService::createString(const char* context, const char* key, const char* value, time_t expiration)
{
Context& ctx = writeContext(context);
SharedLock locker(m_lock, false);
if (i!=ctx.m_dataMap.end()) {
// Not yet expired?
if (time(NULL) < i->second.expiration)
- throw IOException("attempted to insert a record with duplicate key ($1)", params(1,key));
+ return false;
// It's dead, so we can just remove it now and create the new record.
ctx.m_dataMap.erase(i);
}
ctx.m_dataMap[key]=Record(value,expiration);
m_log.debug("inserted record (%s) in context (%s)", key, context);
+ return true;
}
int MemoryStorageService::readString(const char* context, const char* key, string* pvalue, time_t* pexpiration, int version)