123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- /*
- * @Description:
- * @Version: 1.0
- * @Autor: zhuyijun
- * @Date: 2021-11-16 18:57:54
- * @LastEditTime: 2021-11-17 13:24:16
- */
- #include "redis.h"
- int main() {
- Redis *r = new Redis();
- if (!r->connect("127.0.0.1", 6379)) {
- printf("connect error!\n");
- return 0;
- }
- r->set("name", "Andy");
- printf("Get the name is %s\n", r->get("name").c_str());
- bool flag = true;
- while (flag) {
- std::cout << "输入 1 设置, 2 获取 0退出";
- int chonse;
- std::string key;
- std::string value;
- std::cin >> chonse;
- switch (chonse) {
- case 1:
- std::cout << "请输入key value :" << std::endl;
- std::cin >> key >> value;
- r->set(key, value);
- break;
- case 2:
- std::cout << "请输入key :" << std::endl;
- std::cin >> key;
- printf("%s = %s\n", key.c_str(), r->get(key).c_str());
- break;
- case 0:
- flag = false;
- break;
- default:
- printf("\033c");
- std::cout << "请重新输入您的选择 1 设置, 2 获取 0退出:" << std::endl;
- break;
- }
- }
- delete r;
- return 0;
- }
|