Redis:计算Redis集群上的特定类别密钥?(Redis: count specific class of keys on a Redis cluster?)
有没有一种有效的方法来计算Redis集群上的特定类别的密钥?
这里,“特定密钥类”是指用于共同目的的密钥; 例如会话密钥。 他们可以有一个公共密钥名称前缀。 可以有多个类。 从现在开始,我将把键类指定为键。
我想要做的是如下:
- 必须使用Redis群集。
- 密钥必须分配给Redis集群的节点。
- 必须有一种有效的方法来计算Redis群集的所有节点上的密钥数。
- 密钥可以有TTL - 即可以过期。
- Redis集群节点的数量可以在运行时更改,散列槽可以重新分配。
- 客户端使用Node.js实现。
我已阅读文档,但找不到合适的解决方案。
提前致谢。
Is there an efficient method to count specific class of keys on a Redis cluster?
Here, 'specific class of keys' means the keys that are used for a common purpose; for example, session keys. They can have a common key name prefix. There can be multiple classes. From now, I will refer the class of keys as simply the keys.
What I want to do is as follows:
- Redis cluster must be used.
- The keys must be distributed to the nodes of the Redis cluster.
- There must be an efficient way to count the number of the keys on all of the nodes of the Redis cluster.
- The keys can have TTL - that is, can expire.
- The number of the nodes of the Redis cluster can be changed on runtime, and hash slots can be redistributed.
- Clients are implemented using Node.js.
I've read the documentation, but could not find a proper solution.
Thanks in advance.
原文:https://stackoverflow.com/questions/47916482
最满意答案
我能够像这样修复你的例子:
bus = QDBusConnection.systemBus() bus.registerObject('/', self) bus.connect( ...
但是,我必须承认我并不完全理解为什么它有效(也就是说,我找不到任何确凿的文件)。 但是,在尝试建立连接之前,您需要注册接收器对象似乎是有道理的。
I was able to fix your example like this:
bus = QDBusConnection.systemBus() bus.registerObject('/', self) bus.connect( ...
However, I have to admit I don't exactly understand why it works (which is to say, I couldn't find any corroborating documentation). It does seem to make sense that you'd need to register the receiver object before attempting to make the connection, though.
相关问答
更多-
将几个小部件中的相同信号连接到PyQt中的相同功能?(Connect the same signal from several widgets to the same function in PyQt?)[2023-10-01]
您已经自己给出了答案:您必须将sum函数连接到每个QLineEdit的textEdited()信号。 当您将所有这些小部件存储在Python列表中时,可以使用非常少的代码执行此操作: # ...append all line edits to this list: line_edits = [] for le in line_edits: le.textChanged.connect(self.mySumFunction) 如果您需要同时编辑/启用/禁用/清除/ ...所有行编辑,这还有一个优点,即 ... -
我能够像这样修复你的例子: bus = QDBusConnection.systemBus() bus.registerObject('/', self) bus.connect( ... 但是,我必须承认我并不完全理解为什么它有效(也就是说,我找不到任何确凿的文件)。 但是,在尝试建立连接之前,您需要注册接收器对象似乎是有道理的。 I was able to fix your example like this: bus = QDBusConnection.systemB ...
-
我在pyqt中迭代几个小部件的首选方法是将它们存储为列表中的对象。 myButtons = [self.ui.phase_scan_button, self.ui.etalon_scan_button, self.ui.mirror_scan_button, self.ui.gain_scan_button] for button in myButtons: button.clicked.connect(lambda _, b=button: self.scan_callb ...
-
没有收到任何评论或回复,我将回答这个问题,并提供自我提出的信息。 似乎没有用于DBus的有用的C#接口。 (通过使用,我的意思是工作!)我能找到的唯一信息或示例不是最新的,并且似乎没有花费在提供工作界面上。 我决定通过使用C ++实现作为Windows服务编写接口,并且我的C#程序将通过服务发送消息给DBus。 这似乎工作正常,所以满足业务需求。 我很失望,不能让C#到DBus工作,但有很多服务总线实现可以在Windows上工作,所以将来我会考虑实现那些而不是DBus。 如果有人想出一个可行的,有记录的解决 ...
-
您可以使用实用程序dbus-send从命令行发送D-Bus请求。 dbus-send --system --type=signal / com.example.signal_name 或者如果你想用信号发送一些数据 dbus-send --system --type=signal / com.example.signal_name string:"hello" You can use the utility dbus-send to send D-Bus request from the command ...
-
time.sleep()阻塞Qt主循环,因此无法处理窗口重绘事件。 使用QTimer定期调用发出信号的方法,以便定期将控制权返回给Qt事件循环。 time.sleep() blocks the Qt main loop so it can't process window redraw events. Use a QTimer to periodically call a method which emits your signal so that control is returned to the Qt ...
-
将迭代器初始化为您的消息并使用它来解析dbus签名的各个元素。 使用dbus_message_iter_next移动到dbus消息的下一个元素和dbus_message_iter_recurse以进入复杂的单个元素。 例如:考虑签名s(iua {is})。 单个元素是s和(iua {is})。 使用dbus_message_iter_init初始化顶级迭代器。 使用dbus_message_iter_next从s移动到(iua {is})。 将迭代器指向(iua {is})后,使用dbus_message_ ...
-
带有dbus接口的PyQT5在查询时冻结(PyQT4工作的地方)(PyQT5 with dbus interface freezes on interspection (where PyQT4 works))[2021-12-22]
结果是PyQt5你需要使用PyQt5特定的dbus模块提供mainloop: from dbus.mainloop.pyqt5 import DBusQtMainLoop 代替: from dbus.mainloop.qt import DBusQtMainLoop Turns out with PyQt5 you need to use PyQt5 specific dbus module providing the mainloop: from dbus.mainloop.pyqt5 import ... -
您只连接到两个信号过载中的一个。 由于您还没有指定所需的重载,因此将选择默认值 - 在本例中为valueChanged(int) 。 要明确选择两个重载,您需要执行以下操作: self.spb.valueChanged[int].connect(self.onValueChanged) self.spb.valueChanged[str].connect(self.onValueChanged) ... def onValueChanged(self, x): print( ...
-
您的程序有几个问题。 我建议看一下最新的PyQt源中的remotecontrolledcar和pingpong示例,它们非常有用。 需要注意的要点是: 您应该将MyServer实例(而不是ServerAdaptor )传递给registerObject() 将pyqtSlot()装饰器添加到您希望通过D-Bus公开的函数中 在适配器类的顶部调用Q_CLASSINFO() ,而不是在其__init__()函数中调用 使用Q_CLASSINFO()设置“D-Bus接口” 你的内省XML包含一个拼写错误('目录' ...