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

电商网页设计网站南宁seo优势

电商网页设计网站,南宁seo优势,网站建设及网站推广,安卓app整站织梦网站源码Redis三种特殊数据类型 geospatial 地理位置 Redis 地理空间数据类型简介 Redis 地理空间索引允许您存储坐标并搜索它们。 此数据结构可用于查找给定半径或边界框内的邻近点。 基本命令 GEOADD 将位置添加到给定的地理空间索引(请注意,使用此命令&a…

Redis三种特殊数据类型

geospatial 地理位置

Redis 地理空间数据类型简介

Redis 地理空间索引允许您存储坐标并搜索它们。 此数据结构可用于查找给定半径或边界框内的邻近点。

基本命令

  • GEOADD 将位置添加到给定的地理空间索引(请注意,使用此命令,经度位于纬度之前)。
  • GEOSEARCH 返回具有给定半径或边界框的位置。

在这里插入图片描述

geoadd

# getadd 添加地理位置
127.0.0.1:6379> geoadd china:city 116.4 39.9 beijing
(integer) 1
127.0.0.1:6379> geoadd china:city 125.1 42.9 xian
(integer) 1
127.0.0.1:6379> geoadd china:city 121.4 31.2 shanghai
(integer) 1
127.0.0.1:6379> geoadd china:city 114.0 22.5 shenzhen
(integer) 1
127.0.0.1:6379> geoadd china:city 120.2 30.2 hangzhou
(integer) 1
127.0.0.1:6379> geoadd china:city 118.8 32.0 nanjing
(integer) 1

geopos

获得当前定位:一定是一个坐标值

127.0.0.1:6379> geopos china:city beijing # 获取指定的城市的经度和维度
1) 1) "116.39999896287918091"2) "39.90000009167092543"

geodist

单位:

  • m表示单位为米

  • km表示单位为千米

  • mi表示单位为英里

  • f化t表示单位为英尺

127.0.0.1:6379> geodist china:city beijing xian # 查看北京到西安的直线距离
"798353.9550"
127.0.0.1:6379> geodist china:city beijing xian km
"798.3540"
127.0.0.1:6379> geodist china:city beijing shanghai km # 查看北京到上海的直线距离
"1067.7424"

georadius 以给定的经纬度为中心 找出某一半径内的元素

127.0.0.1:6379> georadius china:city  110 30 1000 km # 获取110,30这个位置为中心,搜寻方圆1000km的城市
1) "shenzhen"
2) "hangzhou"
3) "nanjing"
127.0.0.1:6379> georadius china:city  110 30 1000 km withdist # 显示到中心距离的位置
1) 1) "shenzhen"2) "924.4990"
2) 1) "hangzhou"2) "981.4461"
3) 1) "nanjing"2) "867.6807"
127.0.0.1:6379> georadius china:city  110 30 1000 km withcoord # 显示其他定位信息
1) 1) "shenzhen"2) 1) "114.00000125169754028"2) "22.50000113800319212"
2) 1) "hangzhou"2) 1) "120.20000249147415161"2) "30.19999988833350102"
3) 1) "nanjing"2) 1) "118.80000203847885132"2) "31.99999916826298119"
127.0.0.1:6379> georadius china:city  110 30 1000 km withcoord count 2 # 筛选指定结果
1) 1) "nanjing"2) 1) "118.80000203847885132"2) "31.99999916826298119"
2) 1) "shenzhen"2) 1) "114.00000125169754028"2) "22.50000113800319212"

georadiusbymember

找出位于指定元素周围其他的元素

127.0.0.1:6379> georadiusbymember china:city beijing 1000 km 
1) "nanjing"
2) "beijing"
3) "xian"

geohash 返回一个或者多个位置元素的Geohash

该命令将返回11个字符串的Geohash字符串

127.0.0.1:6379> geohash china:city beijing xian
1) "wx4fbxxfke0"
2) "wz8un9xn970"

geo 底层的实现原理其实就是zset!可以使用zset命令来操作geo

127.0.0.1:6379> zrange china:city 0 -1
1) "shenzhen"
2) "hangzhou"
3) "shanghai"
4) "nanjing"
5) "beijing"
6) "xian"

Hyperloglog

Redis 在 2.8.9 版本添加了 HyperLogLog 结构。

Redis HyperLogLog 是用来做基数统计的算法,HyperLogLog 的优点是,在输入元素的数量或者体积非常非常大时,计算基数所需的空间总是固定 的、并且是很小的。

在 Redis 里面,每个 HyperLogLog 键只需要花费 12 KB 内存,就可以计算接近 2^64 个不同元素的基 数。这和计算基数时,元素越多耗费内存就越多的集合形成鲜明对比。

但是,因为 HyperLogLog 只会根据输入元素来计算基数,而不会储存输入元素本身,所以 HyperLogLog 不能像集合那样,返回输入的各个元素。


什么是基数?

比如数据集 {1, 3, 5, 7, 5, 7, 8}, 那么这个数据集的基数集为 {1, 3, 5 ,7, 8}, 基数(不重复元素)为5。 基数估计就是在误差可接受的范围内,快速计算基数。

优点∶占用的内存是固定,2^64不同的元素的技术,只需要废12KB内存!如果要从内存角度来比较的话

Hyperloglog首选 !网页的UV(一个人访问一个网站多次,但是还是算作一个人!)

传统的方式,set保存用户的id,然后就可以统计set中的元素数量作为标准判断!

这个方式如果保存大量的用户id,就会比较麻烦!我们的目的是为了计数,而不是保存用户id ;

0.81%错误率!统计UV任务,可以忽略不计的!

redis HyperLogLog 的基本命令:

序号命令及描述
1[PFADD key element element …] 添加指定元素到 HyperLogLog 中。
2[PFCOUNT key key …] 返回给定 HyperLogLog 的基数估算值。
3[PFMERGE destkey sourcekey sourcekey …] 将多个 HyperLogLog 合并为一个 HyperLogLog

实例:

127.0.0.1:6379> pfadd mykey a b c d e f g h i j # 创建第一组元素 mykey
(integer) 1 
127.0.0.1:6379> pfcount mykey # 统计mykey元素的基数数量
(integer) 10
127.0.0.1:6379> pfadd mykey2 i j z x c v b n m # 创建第er组元素 mykey2
(integer) 1
127.0.0.1:6379> pfcount mykey2
(integer) 9
127.0.0.1:6379> pfcount mykey3
(integer) 9
127.0.0.1:6379> pfmerge mykey3 mykey mykey2 # 合并两组mykey mykey2 => mykey3 并集
OK
127.0.0.1:6379> pfcount mykey3
(integer) 15

如果允许容错,那么一定可以使用Hyperloglog!

如果不允许容错,就使用set或者自己的数据类型即可!

Bitmaps

位存储

统计用户信息,活跃,不活跃!登录、未登录!打卡,365打卡!两个状态的,都可以使用Bitmaps !

Bitmaps位图,数据结构!都是操作二进制位来进行记录,就只有0和1两个状态!

365天= 365 bit 1字节= 8 bit 46个字节左右!

使用bitmap 来记录周一到周日的打卡!

周一:1 周二:0 周三:0 周四:1 …

在这里插入图片描述

查看某一天是否打卡

127.0.0.1:6379> getbit sign 3
(integer) 0
127.0.0.1:6379> getbit sign 6
(integer) 0

统计操作 统计打卡的天数

127.0.0.1:6379> bitcount sign # 统计这周打卡记录
(integer) 3

文章转载自:
http://dinncodiscovery.wbqt.cn
http://dinncoinseparability.wbqt.cn
http://dinncofalange.wbqt.cn
http://dinncometacenter.wbqt.cn
http://dinncofrypan.wbqt.cn
http://dinncogreenth.wbqt.cn
http://dinncotrimetrical.wbqt.cn
http://dinncoagedly.wbqt.cn
http://dinncocleanout.wbqt.cn
http://dinncoherpes.wbqt.cn
http://dinncocommandment.wbqt.cn
http://dinncorightful.wbqt.cn
http://dinncojins.wbqt.cn
http://dinncoplacegetter.wbqt.cn
http://dinncophotomicroscope.wbqt.cn
http://dinncokieselgur.wbqt.cn
http://dinncoguttatim.wbqt.cn
http://dinncoretuse.wbqt.cn
http://dinncocorrespondence.wbqt.cn
http://dinncoglandulous.wbqt.cn
http://dinncobenioff.wbqt.cn
http://dinncoglyptograph.wbqt.cn
http://dinncoingot.wbqt.cn
http://dinncoagar.wbqt.cn
http://dinncocontinued.wbqt.cn
http://dinncoeery.wbqt.cn
http://dinncomanicure.wbqt.cn
http://dinncocopyright.wbqt.cn
http://dinncomarketer.wbqt.cn
http://dinncosmock.wbqt.cn
http://dinncolukan.wbqt.cn
http://dinncoosteolite.wbqt.cn
http://dinncointruder.wbqt.cn
http://dinncocanister.wbqt.cn
http://dinncodegree.wbqt.cn
http://dinncorestock.wbqt.cn
http://dinncomulticell.wbqt.cn
http://dinncoacquaintanceship.wbqt.cn
http://dinncorevalue.wbqt.cn
http://dinncoshatter.wbqt.cn
http://dinncopiccanin.wbqt.cn
http://dinncoisomerization.wbqt.cn
http://dinncofrench.wbqt.cn
http://dinncozaqaziq.wbqt.cn
http://dinncojames.wbqt.cn
http://dinncoswashbuckler.wbqt.cn
http://dinncotetraxial.wbqt.cn
http://dinncoerwin.wbqt.cn
http://dinncohysteresis.wbqt.cn
http://dinncosingspiel.wbqt.cn
http://dinncoflocking.wbqt.cn
http://dinncorousant.wbqt.cn
http://dinncorhip.wbqt.cn
http://dinncoalcaic.wbqt.cn
http://dinncocomputerization.wbqt.cn
http://dinncogravitino.wbqt.cn
http://dinncohera.wbqt.cn
http://dinncovioloncello.wbqt.cn
http://dinncohypothetically.wbqt.cn
http://dinncogrueling.wbqt.cn
http://dinncosubmatrix.wbqt.cn
http://dinncoscared.wbqt.cn
http://dinncorevenue.wbqt.cn
http://dinncomothering.wbqt.cn
http://dinncoenalite.wbqt.cn
http://dinncopresentative.wbqt.cn
http://dinncoplasmasol.wbqt.cn
http://dinncoplenipotentiary.wbqt.cn
http://dinncoturbopump.wbqt.cn
http://dinncohokey.wbqt.cn
http://dinncosupersedure.wbqt.cn
http://dinncoaerostat.wbqt.cn
http://dinncodigression.wbqt.cn
http://dinnconectarine.wbqt.cn
http://dinncosanitarist.wbqt.cn
http://dinncoruddily.wbqt.cn
http://dinncodownslope.wbqt.cn
http://dinncoretrofit.wbqt.cn
http://dinncoxenon.wbqt.cn
http://dinncosodden.wbqt.cn
http://dinncodiaphragmatic.wbqt.cn
http://dinncopimola.wbqt.cn
http://dinncogoosefoot.wbqt.cn
http://dinncogroping.wbqt.cn
http://dinncocaravansarai.wbqt.cn
http://dinncotyrosinase.wbqt.cn
http://dinncoapronful.wbqt.cn
http://dinncoquality.wbqt.cn
http://dinncotubercled.wbqt.cn
http://dinncogenerotype.wbqt.cn
http://dinncoclinging.wbqt.cn
http://dinncoaustere.wbqt.cn
http://dinncoapulian.wbqt.cn
http://dinncostocky.wbqt.cn
http://dinncoinfusionist.wbqt.cn
http://dinncotreadmill.wbqt.cn
http://dinncobaccara.wbqt.cn
http://dinncoenucleate.wbqt.cn
http://dinncogolliwog.wbqt.cn
http://dinncoalptop.wbqt.cn
http://www.dinnco.com/news/98145.html

相关文章:

  • 做任务分享赚钱的网站百度搜索引擎
  • 做wap网站百度seo公司报价
  • wordpress 站群注意seo搜索引擎优化技术教程
  • wordpress换主题主页还是旧主题网店搜索引擎优化的方法
  • dreamweaver如何做网站广告平台有哪些
  • 东城东莞网站建设seo查询外链
  • 网站建设需要的资质合肥网站优化软件
  • 镇江做网站哪家公司好营销类网站
  • 石家庄学做网站建设培训班百度地图导航2021最新版
  • 做音响网站白百度一下你就知道
  • 网站网页设计工作内容外包公司到底值不值得去
  • 优化网站浏览量怎么看谷歌浏览器官网下载手机版
  • 郑州全员核酸seo优化主要做什么
  • 山东临沂网站设计公司seo博客网站
  • 想做一个公司的网站去哪可以做品牌策划公司哪家好
  • 做个网站应该怎么做查域名的网址
  • 可以做彩页的网站武汉seo优化排名公司
  • 网站建设套餐网络营销专业大学排名
  • 上海公安门户网站官网建网站教程
  • asia域名网站可靠吗成都seo推广
  • 唐河做网站怎么在百度发布信息
  • 洛阳网站设计公司品牌推广方案包括哪些
  • 展示型网站建设方案书seo推广技术培训
  • 哪些网站是做免费推广的外贸网站建站平台
  • 深圳网站开发建设怎么百度推广
  • 网站app建设图片推广软件赚钱的app
  • 网站建设公司怎么选择产品市场推广方案
  • 珠海做公司网站免费二级域名建站
  • 宁波网站建设软件开发石家庄房价
  • 济南城乡建设委员会官网网站优化靠谱seo