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代码时模拟黄瓜测试吗。我们应该在多大程度上使用黄瓜?   Hibernate Weblogic 10.3.4 java。lang.NoSuchMethodError:javax/persistence/spi/PersistenceUnitInfo。getValidationMode()Ljavax/persistence/ValidationMode;   java如何在main()中访问私有静态实例变量   java JMockit无法模拟类的公共final字段   java是否可以返回特定控制器操作的输出(html)?   java如何返回正确类型的列表?   rest-OpenUI/Swagger-java-to-API   java组织。springframework。豆。工厂NoSuchBeanDefinitionException或加载ApplicationContext失败   java使用POST将参数从JSP发送到Servlet   java如何监听特定的按钮按下和主视图用户交互?   java如何让gradle在本地maven repo中覆盖库?   如何在Java中“合并”两个URI?   java如何制作一个方法来移动数组中的字符?   使用来自java的命令启动powershell窗口   java垃圾收集器和匿名类   java如何为CellTable(GWT 2.4)中的ImageResourceCell创建PanelPopup?