我在redis中使用"KEYS p_*"命令获取值.
但是使用"KEYS p_*",如果redis有数百万个键,我会得到太多的值和糟糕的表现.
那么我可以用"KEYS p_*"命令获得100个值吗?
这是我的代码:
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
class TestLog: public std::stringstream
{
public:
~TestLog()
{
cout << (str()) << endl; // Why does this print an address ?
}
};
int main()
{
TestLog() << "Hello World!"; //test 1 print an address
stringstream ss;
ss << "Hello World!";
cout << (ss.str()) << endl; //test 2 print a string
return 0;
}
Run Code Online (Sandbox Code Playgroud)
并输出:
0x401b90
你好,世界!
编译器信息:
g ++(GCC)4.8.5 20150623(Red Hat 4.8.5-11)
在我看来,(a)std :: stringstream的str()方法返回一个字符串.(b)std :: cout是std :: ostream的对象.因此,两个测试都将调用ostream的相同运算符函数并打印相同的"Hello …