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在AlertDialog builder标题右侧放置图标   安装weblogic server12时发生java获取错误。1在windows 10上   java无法导入:安卓。支持v7。小装置。Android Studio中的RecyclerView   java Android应用程序等待通知奇怪行为   java如何比较ArrayList中的整数元素?   java Quartz属性不会触发Quartz作业   java轻松地将许多JavaFX属性绑定到UINode   Maven插件管理器导致java错误消息的原因是什么?   JAXB解组错误后java文件被阻止   java如何在spark kafka流中创建消费者组并将消费者分配给消费者组   java Gps lat&long随机显示非常不准确的结果   java使用assest文件夹文件在Android上执行shell命令   java如何在客户端使用javascript提取文本   java扩展描述的distincts之和   java重写默认Spring数据REST配置   java SQL未命名参数语法   二进制搜索任务的java真实解决方案   java在一个多模块多数据源项目中,用什么正确的方式来指示将哪个数据源注入我的DAOs?