Last active
February 22, 2017 21:32
-
-
Save MikeGoldsmith/0cf4fa0f4d04948068a136186b979119 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MemcachedBinprotConnection connection( | |
"127.0.0.1", | |
11210, | |
AF_INET, | |
false); | |
connection.authenticate("trond", "password", "PLAIN"); | |
connection.hello("rbac_demo", MEMCACHED_VERSION, "RBAC demo code"); | |
connection.setXerrorSupport(true); | |
const auto buckets = connection.listBuckets(); | |
std::cout << "The user trond have access to: [ "; | |
for (const auto& bucket : buckets) { | |
std::cout << bucket << " "; | |
} | |
std::cout << "]" << std::endl; | |
std::cout << "Create document in buckets: " << std::endl; | |
// Let's try to create a document in each of the buckets | |
for (const auto& bucket : buckets) { | |
connection.selectBucket(bucket); | |
std::cout << "\t" << bucket << " - " | |
<< memcached_status_2_text(create_document(connection)) | |
<< std::endl; | |
} | |
try { | |
connection.selectBucket("no-access-bucket"); | |
} catch (const ConnectionError& ex) { | |
std::cout << ex.what() << std::endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment