我想使用 redis 有效搜索 IPv6 子网范围。
我想到将 IPv6 数字地址存储在 redis 中并按范围搜索它们。这些是128 位 int,例如:
import ipaddress
int(ipaddress.ip_address(u'113f:a:2:3:4:1::77'))
> 22923991422715307029586104612626104439L
Run Code Online (Sandbox Code Playgroud)
并按范围查询:
ZRANGEBYSCORE numerics <subnet-S-start> <subnet-S-end>
Run Code Online (Sandbox Code Playgroud)
然而,redis 排序集最多可以容纳 2^53 的分数,因此我所有的大整数都被修剪,并且我失去了精度。
有没有办法在redis中保存如此大的数字而不损失精度?
您有更好的建议吗?谢谢