diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-23 05:25:45 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-23 05:25:45 +0000 |
commit | e5d978186780787e8dad6681cca139486df93643 (patch) | |
tree | 85a837c0e230de4144743f090b2fe714cbb29fec /sca-cpp/trunk/components/cache/mcache-test.cpp | |
parent | 585f81b9436e137c3ed784d9a91efa9e6e792e03 (diff) |
Refactored memcached support into an SCA component. Moved cache monad functions to kernel.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@883250 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r-- | sca-cpp/trunk/components/cache/mcache-test.cpp (renamed from sca-cpp/trunk/modules/cache/memcache-test.cpp) | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/sca-cpp/trunk/modules/cache/memcache-test.cpp b/sca-cpp/trunk/components/cache/mcache-test.cpp index 3522094126..3f02b649d6 100644 --- a/sca-cpp/trunk/modules/cache/memcache-test.cpp +++ b/sca-cpp/trunk/components/cache/mcache-test.cpp @@ -29,21 +29,20 @@ #include <iostream> #include <string> #include <fstream> -#include "memcached.hpp" +#include "mcache.hpp" namespace tuscany { namespace cache { bool testMemCached() { - memcached::Cache cache; - memcached::addServer("localhost", 11311, cache); + MemCached ch("localhost", 11311); - assert(hasValue(memcached::post("a", "AAA", cache))); - assert(memcached::get("a", cache) == value(std::string("AAA"))); - assert(hasValue(memcached::put("a", "aaa", cache))); - assert(memcached::get("a", cache) == value(std::string("aaa"))); - assert(hasValue(memcached::del("a", cache))); - assert(!hasValue(memcached::get("a", cache))); + assert(hasContent(post("a", "AAA", ch))); + assert(get("a", ch) == value(std::string("AAA"))); + assert(hasContent(put("a", "aaa", ch))); + assert(get("a", ch) == value(std::string("aaa"))); + assert(hasContent(del("a", ch))); + assert(!hasContent(get("a", ch))); return true; } @@ -53,11 +52,11 @@ const double duration(struct timeval start, struct timeval end, int count) { return (double)t / (double)count; } -bool testGetLoop(const int count, memcached::Cache& cache) { +bool testGetLoop(const int count, MemCached& ch) { if (count == 0) return true; - assert(memcached::get("c", cache) == value(std::string("CCC"))); - return testGetLoop(count - 1, cache); + assert(get("c", ch) == value(std::string("CCC"))); + return testGetLoop(count - 1, ch); } bool testGetPerf() { @@ -65,15 +64,14 @@ bool testGetPerf() { struct timeval start; struct timeval end; { - memcached::Cache cache; - memcached::addServer("localhost", 11311, cache); - assert(hasValue(memcached::post("c", "CCC", cache))); + MemCached ch("localhost", 11311); + assert(hasContent(post("c", "CCC", ch))); - testGetLoop(5, cache); + testGetLoop(5, ch); gettimeofday(&start, NULL); - testGetLoop(count, cache); + testGetLoop(count, ch); gettimeofday(&end, NULL); std::cout << "Memcached get test " << duration(start, end, count) << " ms" << std::endl; |