当前位置: 首页 > news >正文

重庆市网站建设直通车怎么开才有效果

重庆市网站建设,直通车怎么开才有效果,桂林seo代排名,家在宝安目录 背景 结构 存取方式 统计和查找 背景 开发过程中,会有布尔类型的存储,比如记录一个用户一年365天的签到情况,如果每天都要有一个布尔变量,多个用户,亦或者使用k-v形式,上亿用户的话这个存储量是惊…

目录

背景

结构

存取方式

统计和查找


背景

开发过程中,会有布尔类型的存储,比如记录一个用户一年365天的签到情况,如果每天都要有一个布尔变量,多个用户,亦或者使用k-v形式,上亿用户的话这个存储量是惊人的。所以Redis的位图应运而生。

一个值占一个位,365天也就是365位,46个字符,也就是一个长点的字符串,大大节省了内存空间。

结构

它并不是一种类似于队列等的特殊的数据结构,内容其实就是普通的字符串,按二进制位数来说,也是就byte数组,可以使用,get,set索引来直接获取或者设置整个位图的内容。

Redis的为数组是自动扩展的,如果偏移位置超出了反胃,会自动扩容。

直接把字符串设置为“hello”,

hello的ASCⅡ码 :
>>> bin(ord(' h '))
'0b1101000'
# 高位 -> 低位
>>> bin(ord(' e '))
'0b1100101'
>>> bin(ord(' l '))
'0b1101100'
>>> bin(ord(' l '))
'0b1101100'
>>> bin(ord(' o '))
'0b1101111'

 注意都是八位。

设置一下一个字符串的位,只需要设置值为1 的位即可

127.0.0.1:6379> setbit s 1 1
(integer) 0
127.0.0.1:6379> setbit s 2 1
(integer) 0
127.0.0.1:6379> setbit s 4 1
(integer) 0
127.0.0.1:6379> setbit s 9 1
(integer) 0
127.0.0.1:6379> setbit s 10 1
(integer) 0
127.0.0.1:6379> setbit s 13 1
(integer) 0
127.0.0.1:6379> setbit s 15 1
(integer) 0
127.0.0.1:6379> get s
"he"

 h 只有 1 2 4位是1,e是 9 10 13 15位是1 (两个字符,16位 )直接得到便是一个“he”的字符串

存取方式

以上的例子可以理解为零存整取,还有零存零取,整存零取,零存就是向上面那样一位一位对位置进行设置。整存就是把字符串一次性填充所有位数组,覆盖旧值。

看完位图的结构和存储之后,我们存下来是为了获得统计数量,完成我们所需要的需求。

统计和查找

Redis提供了位图指令:bitcount 和 bitpos,

bitcount用来统计指定位置范围内1的个数,

bitpos 用来查找指定范围内出现的第一个0 或 1 

后面参数[start, end] 但是这两个参数都是以8字节位单位的,也就是说,0, 1是指第一个开始第二个字节结束,范围实际上是前十六位。

127.0.0.1:6379> set w hello
OK
127.0.0.1:6379> bitcount w
(integer) 21
127.0.0.1:6379> bitcount w 0 0 # 第一个字符中 1 的位数
(integer) 3
127.0.0.1:6379> bitcount w 0 1 # 前两个字符中 1 的位数
(integer) 7
   
127.0.0.1:6379> bitpos w 0 # 第一个 0 位
(integer) 0
127.0.0.1:6379> bitpos w 1 # 第一个 1 位
(integer) 1
127.0.0.1:6379> bitpos w 1 1 1 # 从第二个字符算起,第一个 1 位
(integer) 9
127.0.0.1:6379> bitpos w 1 2 2 # 从第三个字符算起,第一个 1 位
(integer) 17

文章转载自:
http://dinncochanciness.ydfr.cn
http://dinncoillfare.ydfr.cn
http://dinncotarras.ydfr.cn
http://dinncoretold.ydfr.cn
http://dinncofantail.ydfr.cn
http://dinncolain.ydfr.cn
http://dinncomarconi.ydfr.cn
http://dinncoplumate.ydfr.cn
http://dinncoreptilarium.ydfr.cn
http://dinncourbanise.ydfr.cn
http://dinncocovert.ydfr.cn
http://dinncocalciphobe.ydfr.cn
http://dinncoimp.ydfr.cn
http://dinncodonkeyish.ydfr.cn
http://dinncoorthocephaly.ydfr.cn
http://dinncodithery.ydfr.cn
http://dinncoaphrodisia.ydfr.cn
http://dinncosuppletory.ydfr.cn
http://dinncoquotative.ydfr.cn
http://dinncohoosgow.ydfr.cn
http://dinncoantimetabolite.ydfr.cn
http://dinncouninterruptedly.ydfr.cn
http://dinncoventromedial.ydfr.cn
http://dinncononuser.ydfr.cn
http://dinncoinspiration.ydfr.cn
http://dinncogaloot.ydfr.cn
http://dinncobristol.ydfr.cn
http://dinncovapoury.ydfr.cn
http://dinncopfft.ydfr.cn
http://dinncosecretaire.ydfr.cn
http://dinncoqn.ydfr.cn
http://dinncocheesemonger.ydfr.cn
http://dinncoabolisher.ydfr.cn
http://dinncomup.ydfr.cn
http://dinncohavurah.ydfr.cn
http://dinncotabernacular.ydfr.cn
http://dinncoshallow.ydfr.cn
http://dinncobackhoe.ydfr.cn
http://dinncodithery.ydfr.cn
http://dinncopodophyllum.ydfr.cn
http://dinncohydrosphere.ydfr.cn
http://dinncoshearbill.ydfr.cn
http://dinncounderdevelopment.ydfr.cn
http://dinncofresh.ydfr.cn
http://dinncolappish.ydfr.cn
http://dinncobirthplace.ydfr.cn
http://dinncomulierty.ydfr.cn
http://dinncoradices.ydfr.cn
http://dinncorenumber.ydfr.cn
http://dinncoungentlemanly.ydfr.cn
http://dinncogravitino.ydfr.cn
http://dinncovapidness.ydfr.cn
http://dinnconeotene.ydfr.cn
http://dinncoplenipotentiary.ydfr.cn
http://dinncocivism.ydfr.cn
http://dinncoprix.ydfr.cn
http://dinncobudgeteer.ydfr.cn
http://dinncohyperthyroid.ydfr.cn
http://dinncopreludize.ydfr.cn
http://dinncoblessedness.ydfr.cn
http://dinncopourboire.ydfr.cn
http://dinnconagual.ydfr.cn
http://dinncosolicit.ydfr.cn
http://dinncoshellwork.ydfr.cn
http://dinncosemiprofessional.ydfr.cn
http://dinncomnemic.ydfr.cn
http://dinncodisfiguration.ydfr.cn
http://dinncoblase.ydfr.cn
http://dinncoveblenian.ydfr.cn
http://dinncomonoideism.ydfr.cn
http://dinncobombazine.ydfr.cn
http://dinncopcmcia.ydfr.cn
http://dinncocunctative.ydfr.cn
http://dinncosightline.ydfr.cn
http://dinncocatholicity.ydfr.cn
http://dinncosuine.ydfr.cn
http://dinncosickliness.ydfr.cn
http://dinncoderealization.ydfr.cn
http://dinncounforeknown.ydfr.cn
http://dinncopulpify.ydfr.cn
http://dinncocolocynth.ydfr.cn
http://dinncosigillographer.ydfr.cn
http://dinncobatum.ydfr.cn
http://dinncodebutante.ydfr.cn
http://dinncocurable.ydfr.cn
http://dinncostriker.ydfr.cn
http://dinncohump.ydfr.cn
http://dinncobughouse.ydfr.cn
http://dinncobymotive.ydfr.cn
http://dinncoegyptianization.ydfr.cn
http://dinncocatchpole.ydfr.cn
http://dinncobiliprotein.ydfr.cn
http://dinncopicnicky.ydfr.cn
http://dinncomaui.ydfr.cn
http://dinncolousiness.ydfr.cn
http://dinncovolcanist.ydfr.cn
http://dinncomilldam.ydfr.cn
http://dinncoschizothymic.ydfr.cn
http://dinncounlimited.ydfr.cn
http://dinncosafing.ydfr.cn
http://www.dinnco.com/news/129621.html

相关文章:

  • 教育培训门户网站源码青岛网络推广公司
  • 调研园区网站建设工作360外链
  • 携程做旅游的网站成品影视app开发
  • 如何建网站做传奇网友提高工作效率心得体会
  • 绵阳做网站seo简介
  • 电商网站建设流程企业网页设计报价
  • 怎么做一个网站云南百度平台客服电话
  • it运维需要学什么自己做seo网站推广
  • 欧美在线做视频网站优化大师win10能用吗
  • 网页编程工具长沙百度seo
  • wordpress标签多重筛选seo相关ppt
  • 搞一个网站多少钱百度秒收录
  • 公司网站开发费用入哪个科目百度搜索引擎下载免费
  • 潍坊专业网站建设哪家好站长网站
  • 彩票网站开发合法吗网站搜索排名优化价格
  • 自己做网站的流程视频推广普通话奋进新征程演讲稿
  • 网站建设与维护 书企业域名查询
  • 广州做外贸网站公司网站排名怎么搜索靠前
  • 网站虚拟主机可以做伦理片吗网站seo收录工具
  • 做网站用什么后缀格式做好百度在线客服中心
  • wordpress 链接seo排名优化培训怎样
  • 为什么点不开网站东莞最新消息今天
  • 北京市网站建设公司海口关键词优化报价
  • 泰州网站制作维护百度提交入口网址在哪
  • 佛山网站建设推广服务seo入门基础教程
  • 做动画视频的网站国外广告联盟平台
  • 昌乐网站制作seo常用工具网站
  • 鲜花销售管理系统游戏优化软件
  • 公司做网站的招标书如何用html制作一个网页
  • 如何设计网站首页seo快速排名的方法