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
2024-04-11 14:04

满意答案

我能够像这样修复你的例子:

    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?)

您已经自己给出了答案:您必须将sum函数连接到每个QLineEdit的textEdited()信号。 当您将所有这些小部件存储在Python列表中时,可以使用非常少的代码执行此操作: # ...append all line edits to this list: line_edits = [] for le in line_edits: le.textChanged.connect(self.mySumFunction) 如果您需要同时编辑/启用/禁用/清除/ ...所有行编辑,这还有一...

PyQt 5.6:连接到DBus信号挂起(PyQt 5.6: connecting to a DBus signal hangs)

我能够像这样修复你的例子: bus = QDBusConnection.systemBus() bus.registerObject('/', self) bus.connect( ... 但是,我必须承认我并不完全理解为什么它有效(也就是说,我找不到任何确凿的文件)。 但是,在尝试建立连接之前,您需要注册接收器对象似乎是有道理的。 I was able to fix your example like this: bus = QDBusConnection.sy...

在pyqt中以for循环连接多个信号/槽(Connecting multiples signal/slot in a for loop in pyqt)

我在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_...

连接到示例DBus守护程序的C#程序总是获取'访问被拒绝:DBus.BusObject'(C# program connecting to example DBus daemon always gets 'Access is denied: DBus.BusObject')

没有收到任何评论或回复,我将回答这个问题,并提供自我提出的信息。 似乎没有用于DBus的有用的C#接口。 (通过使用,我的意思是工作!)我能找到的唯一信息或示例不是最新的,并且似乎没有花费在提供工作界面上。 我决定通过使用C ++实现作为Windows服务编写接口,并且我的C#程序将通过服务发送消息给DBus。 这似乎工作正常,所以满足业务需求。 我很失望,不能让C#到DBus工作,但有很多服务总线实现可以在Windows上工作,所以将来我会考虑实现那些而不是DBus。 如果有人想出一个可行的,有...

如何从命令行发出dbus信号(How to emit dbus signal from command line)

您可以使用实用程序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 co...

PyQt4:仅处理最后一个信号(PyQt4: Only the last signal is being processed)

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 t...

如何接收使用dbus作为信号发送的结构?(How to receive a struct which was sent as a signal using dbus?)

将迭代器初始化为您的消息并使用它来解析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_mes...

带有dbus接口的PyQT5在查询时冻结(PyQT4工作的地方)(PyQT5 with dbus interface freezes on interspection (where PyQT4 works))

结果是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 im...

PyQt5:根据文档,一个信号而不是两个(PyQt5: one signal comes instead of two as per documentation)

您只连接到两个信号过载中的一个。 由于您还没有指定所需的重载,因此将选择默认值 - 在本例中为valueChanged(int) 。 要明确选择两个重载,您需要执行以下操作: self.spb.valueChanged[int].connect(self.onValueChanged) self.spb.valueChanged[str].connect(self.onValueChanged) ... def onValueChanged(self, x): p...

如何使用带有PyQt4的QDBusAbstractAdaptor在DBus上公开方法和属性?(How does one expose methods and properties on DBus using a QDBusAbstractAdaptor with PyQt4?)

您的程序有几个问题。 我建议看一下最新的PyQt源中的remotecontrolledcar和pingpong示例,它们非常有用。 需要注意的要点是: 您应该将MyServer实例(而不是ServerAdaptor )传递给registerObject() 将pyqtSlot()装饰器添加到您希望通过D-Bus公开的函数中 在适配器类的顶部调用Q_CLASSINFO() ,而不是在其__init__()函数中调用 使用Q_CLASSINFO()设置“D-Bus接口” 你的内省XML包含一个拼写错误...

相关文章

更多

redis 集群环境搭建-redis集群管理

集群架构 (1)所有的redis节点彼此互联(PING-PONG机制),内部使用二进制协议优化传输速度 ...

redis 集群使用主从复制架构-redis集群管理

redis集群使用主从架构如下图,能有效解决集群中节点连接不上造成集群挂掉的情况 a) 在Redis ...

Redis Cookbook

Two years since its initial release, Redis already ...

redis新增集群节点-redis集群管理

新增一个节点6383,并启动 执行redis-trib.rb add-node命令添加节点 redi ...

Redis 哈希(Hash)详解

Redis hash 是一个string类型的field和value的映射表,hash特别适合用于存储 ...

redis删除集群节点-redis集群管理

先查看一下集群节点信息: 192.168.56.101:6382> cluster nodes 0 ...

redis集群插槽分配-redis集群管理

使用cluster nodes命令查看当前集群信息 192.168.56.101:6382> ...

redis集群出现宕机没法访问-redis集群管理

先来查看集群节点信息 192.168.56.101:6382> cluster nodes ...

redis sentinel.conf详解-redis集群管理

sentinel.conf详解 官方完整示例

最新问答

更多

获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)

我用Google搜索了一个解决方案。 “EnumDisplayModeProvider”是我自己设置网站的各种模式的枚举。 public EnumDisplayModeProvider GetDisplayModeId() { foreach (var mode in DisplayModeProvider.Instance.Modes) if (mode.CanHandleContext(HttpContext)) {

如何通过引用返回对象?(How is returning an object by reference possible?)

这相对简单:在类的构造函数中,您可以分配内存,例如使用new 。 如果你制作一个对象的副本,你不是每次都分配新的内存,而是只复制指向原始内存块的指针,同时递增一个也存储在内存中的引用计数器,使得每个副本都是对象可以访问它。 如果引用计数降至零,则销毁对象将减少引用计数并仅释放分配的内存。 您只需要一个自定义复制构造函数和赋值运算符。 这基本上是共享指针的工作方式。 This is relatively easy: In the class' constructor, you allocate m

矩阵如何存储在内存中?(How are matrices stored in memory?)

正如它在“熵编码”中所说的那样,使用Z字形图案,与RLE一起使用,在许多情况下,RLE已经减小了尺寸。 但是,据我所知,DCT本身并没有给出稀疏矩阵。 但它通常会增强矩阵的熵。 这是compressen变得有损的点:输入矩阵用DCT传输,然后量化量化然后使用霍夫曼编码。 As it says in "Entropy coding" a zig-zag pattern is used, together with RLE which will already reduce size for man

每个请求的Java新会话?(Java New Session For Each Request?)

你是如何进行重定向的? 您是否事先调用了HttpServletResponse.encodeRedirectURL()? 在这里阅读javadoc 您可以使用它像response.sendRedirect(response.encodeRedirectURL(path)); The issue was with the path in the JSESSIONID cookie. I still can't figure out why it was being set to the tomca

css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)

我认为word-break ,如果你想在一个单词中打破行,你可以指定它,这样做可以解决问题: .column { word-break:break-all; } jsFiddle演示。 您可以在此处阅读有关word-break属性的更多信息。 I think word-break, with which you can specify if you want to break line within a word, will do the trick: .column { word-break

无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)

我认为您忘记在分类时间内缩放输入图像,如train_test.prototxt文件的第11行所示。 您可能应该在C ++代码中的某个位置乘以该因子,或者使用Caffe图层来缩放输入(请查看ELTWISE或POWER图层)。 编辑: 在评论中进行了一次对话之后,结果发现在classification.cpp文件中错误地删除了图像均值,而在原始训练/测试管道中没有减去图像均值。 I think you have forgotten to scale the input image during cl

xcode语法颜色编码解释?(xcode syntax color coding explained?)

转到: Xcode => Preferences => Fonts & Colors 您将看到每个语法高亮颜色旁边都有一个简短的解释。 Go to: Xcode => Preferences => Fonts & Colors You'll see that each syntax highlighting colour has a brief explanation next to it.

在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)

你考虑过第三方拼写检查吗? 您可以将在C#中开发的自定义WinForms控件插入访问数据库吗? VB6控件怎么样? 如果你能找到一个使用第三方库进行拼写检查的控件,那可能会有效。 Have you considered a third party spell checker? Can you insert a custom WinForms controls developed in C# into an access database? What about a VB6 control? If

从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)

我有同样的问题,因为我在远程服务器上有两个图像,我需要在每天的预定义时间复制到我的本地服务器,这是我能够提出的代码... try { if(@copy('url/to/source/image.ext', 'local/absolute/path/on/server/' . date("d-m-Y") . ".gif")) { } else { $errors = error_get_last(); throw new Exception($err

从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))

我不确定我完全明白你在说什么。 你能编辑你的帖子并包含你正在做的Subversion命令/操作的特定顺序吗? 最好使用命令行svn客户端,以便容易为其他人重现问题。 如果您只是想获取文件的旧副本(即使该文件不再存在),您可以使用如下命令: svn copy ${repo}/trunk/moduleA/file1@${rev} ${repo}/trunk/moduleB/file1 其中${repo}是您的存储库的URL, ${rev}是您想要的文件的版本。 这将恢复该文件的旧版本,包括最高版本