diff options
Diffstat (limited to 'sca-cpp/trunk/components/cache/memcache.hpp')
-rw-r--r-- | sca-cpp/trunk/components/cache/memcache.hpp | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/sca-cpp/trunk/components/cache/memcache.hpp b/sca-cpp/trunk/components/cache/memcache.hpp index e4cdceb6fa..5d23ff7c42 100644 --- a/sca-cpp/trunk/components/cache/memcache.hpp +++ b/sca-cpp/trunk/components/cache/memcache.hpp @@ -94,11 +94,14 @@ private: const failable<bool> addServer(const string& host, const int port) { apr_memcache_server_t *server; const apr_status_t sc = apr_memcache_server_create(pool, c_str(host), (apr_port_t)port, 1, 1, 1, 600, &server); - if (sc != APR_SUCCESS) - return mkfailure<bool>("Could not create memcached server"); + if (sc != APR_SUCCESS) { + ostringstream os; + os << "Couldn't connect to memcached server: " << host << ":" << port; + return mkfailure<bool>(str(os)); + } const apr_status_t as = apr_memcache_add_server(mc, server); if (as != APR_SUCCESS) - return mkfailure<bool>("Could not add memcached server"); + return mkfailure<bool>("Couldn't add memcached server"); return true; } @@ -134,8 +137,11 @@ const failable<bool> post(const value& key, const value& val, const MemCached& c const string ks(scheme::writeValue(key)); const string vs(scheme::writeValue(val)); const apr_status_t rc = apr_memcache_add(cache.mc, nospaces(c_str(ks)), const_cast<char*>(c_str(vs)), length(vs), 0, 27); - if (rc != APR_SUCCESS) - return mkfailure<bool>("Could not add memcached entry"); + if (rc != APR_SUCCESS) { + ostringstream os; + os << "Couldn't add memcached entry: " << key; + return mkfailure<bool>(str(os)); + } debug(true, "memcache::post::result"); return true; @@ -151,8 +157,11 @@ const failable<bool> put(const value& key, const value& val, const MemCached& ca const string ks(scheme::writeValue(key)); const string vs(scheme::writeValue(val)); const apr_status_t rc = apr_memcache_set(cache.mc, nospaces(c_str(ks)), const_cast<char*>(c_str(vs)), length(vs), 0, 27); - if (rc != APR_SUCCESS) - return mkfailure<bool>("Could not set memcached entry"); + if (rc != APR_SUCCESS) { + ostringstream os; + os << "Couldn't set memcached entry: " << key; + return mkfailure<bool>(str(os)); + } debug(true, "memcache::put::result"); return true; @@ -168,8 +177,11 @@ const failable<value> get(const value& key, const MemCached& cache) { char *data; apr_size_t size; const apr_status_t rc = apr_memcache_getp(cache.mc, cache.pool, nospaces(c_str(ks)), &data, &size, NULL); - if (rc != APR_SUCCESS) - return mkfailure<value>("Could not get memcached entry"); + if (rc != APR_SUCCESS) { + ostringstream os; + os << "Couldn't get memcached entry: " << key; + return mkfailure<value>(str(os)); + } const value val(scheme::readValue(string(data, size))); debug(val, "memcache::get::result"); @@ -184,8 +196,11 @@ const failable<bool> del(const value& key, const MemCached& cache) { const string ks(scheme::writeValue(key)); const apr_status_t rc = apr_memcache_delete(cache.mc, nospaces(c_str(ks)), 0); - if (rc != APR_SUCCESS) - return mkfailure<bool>("Could not delete memcached entry"); + if (rc != APR_SUCCESS) { + ostringstream os; + os << "Couldn't delete memcached entry: " << key; + return mkfailure<bool>(str(os)); + } debug(true, "memcache::delete::result"); return true; |