RB3,The redis blaster which support pyton 3.7

rb3的Python项目详细描述


RB3,RB叉支撑python3.7

getsentry/rb

相比的变化

不是兼容性升级。

在这个版本中,rb的这个fork只支持python3.7+(python3.5+已经过测试,但不推荐使用)。

目前,我们关注如何使rb在python3.7下工作,就像它在python2.7上工作一样。

变化crc32

现在,我们决定通过编辑rb/router.py

classPartitionRouter(BaseRouter):"""A straightforward router that just individually routes commands to    single nodes based on a simple ``crc32 % node_count`` setup.    This router requires that the hosts are gapless which means that    the IDs for N hosts range from 0 to N-1.    ``crc32`` returns different value in Python2 and Python3, for details    check this link: https://bugs.python.org/issue22341.    """def__init__(self,cluster):BaseRouter.__init__(self,cluster)assert_gapless_hosts(self.cluster.hosts)defget_host_for_key(self,key):ifisinstance(key,text_type):k=key.encode('utf-8')else:k=bytes_type(key)# Make sure return value same as in Python3# return (crc32(k) & 0xffffffff) % len(self.cluster.hosts)# Make sure return value same as in Python2crc_res=crc32(k)crc_res=(crc_res-((crc_res&0x80000000)<<1))returncrc_res%len(self.cluster.hosts)

但将来可能会转而使用python 3的本机crc32函数。

待办事项

  • []选择crc32方法的选项
  • []修复MacOS Travis测试
  • []修复pypy travis测试

RB的原始自述文件

logo

RB-Redis爆炸机。

与许多redis节点通信的最快方式。也可以进行路由 盲目地向多个节点发送命令。它是如何工作的?

有关完整文档,请参见rb.rtfd.org

快速启动

设置群集:

fromrbimportClustercluster=Cluster({0:{'port':6379},1:{'port':6380},2:{'port':6381},3:{'port':6382},},host_defaults={'host':'127.0.0.1',})

自动路由:

results=[]withcluster.map()asclient:forkeyinrange(100):client.get(key).then(lambdax:results.append(int(xor0)))print('Sum: %s'%sum(results))

扇出:

withcluster.fanout(hosts=[0,1,2,3])asclient:infos=client.info()

全部扇出:

withcluster.fanout(hosts='all')asclient:client.flushdb()

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
安卓在java中加入字符串组以创建复合字符串   java系统甚至不点击“下一步”或“上一步”按钮就将我返回到上一页,而不是进入下一页   java如何在arrayList中获取特定列的不同值   CXF GZIP REST JAVA   Java:使用大量半恒定标志检查优化循环中的循环?   java如何在两个应用程序之间进行会话管理?   java SVG文件使用蜡染(但没有轴线)转换为PNG   使用协议缓冲区和内部数据模型的java   java如何在logtag 安卓中打印和查看字符串的值   javascript如何在NodeJs中应用Java/Spring的分层架构?   java Spring URL在JSP中编码不正确   模式对话框后面的java工具提示   java WSRPC生成日历对象而不是日期   在对象外部无法识别类变量   java将图像从文件读/写到BuffereImage的最快方法?   JavaSpring数据存储库对具有不同Id的子类使用抽象超类   安全在Java 5.0上运行web应用程序服务器有危险吗?