小编杜智超*_*杜智超的帖子

redis如何限制KEYS命令的返回次数?

我在redis中使用"KEYS p_*"命令获取值.

但是使用"KEYS p_*",如果redis有数百万个键,我会得到太多的值和糟糕的表现.

那么我可以用"KEYS p_*"命令获得100个值吗?

redis

19
推荐指数
1
解决办法
2万
查看次数

cout一个字符串流但打印一个指针

这是我的代码:

#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 …

c++ c++03

0
推荐指数
1
解决办法
562
查看次数

标签 统计

c++ ×1

c++03 ×1

redis ×1