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

网站建站模式广东免费网络推广软件

网站建站模式,广东免费网络推广软件,wordpress 文章标题列表,阿里巴巴国际站费用redis的数据类型: string类型 设置key及value key的命名规范 key是给存储在redis内存中的数据起的变量名字 在redis里边,key的命令规则不同于一般语言,键盘上除了【空格】【\n换行】不能作为名字的组成内容外,其他的大部分字符都可…

redis的数据类型:

string类型

设置key及value

56f625c90e626e3f5a16565f1f30874f.png

key的命名规范

key是给存储在redis内存中的数据起的变量名字

在redis里边,key的命令规则不同于一般语言,键盘上除了【空格】【\n换行】不能作为名字的组成内容外,其他的大部分字符都可以使用,比如(像my  key和mykey\n这样包含空格和换行的key是不允许的)。

名字长度不做要求,但也不要太长,占内存,查询慢,也不要太短,像u:100:pwd就不如user:100:password可读性好。

value的类型:strings\Lists\Sets\Sorted Sets\Hash

后面会重点讲解这几种类型。

注意:username这个key没有的话会创建,有的话,就会覆盖。
获取key及value

57d8f754284e66576eafd22061de3bb8.png

incr做自增操作,可以对某个key的value进行+1的操作

dc6e6f6b95d29edab4ec9d7040326a95.png

decr做自减操作,可以对某个key的value进行-1操作

f704c90391f3db3b2d44f3f0c9fef663.png

54ec93cae4f80c7d5acf4412e6933f49.png

incrby指定需要增加的数

55be1b5c4ea7929c978a70ac17454ec7.png

2c49a3f0c762dd4fcd6bad22fe68f8dd.png

decrby指定需要减去的数

f9b64dc9ecfe164f86fc28b00dd86236.png

560d382a73ecc0baf07b034c8690f43e.png

keys *:获取redis里面的所有的key

b8466dd42850d78be0238129e51ea3c0.png

一般redis的key是如何设计的???

思考:原先在mysql里面数据是如何存储的???

答:表使用行和列的组合,以【it_user】表为例。

a89fa6e52d9ec1e567621ad212ef1f0a.png

如果需要把上面的mysql里面的表里面的数据存储redis里面,存储的key该如何设计???

答:分如下几步来操作:

ab724fe592917c194094ebcd34791629.png

把上面mysql表里面的记录保存在redis:
第一条记录的语句如下:

37cac0a27cf97fda77b42c572f84b83d.png

第二条记录的语句如下:

83e631dbeac25e9078a8de6893d5b351.png

获取用户的信息,例如要获取用户id为1的信息:

f7ad4e175bf663165023f17c7cd3940d.png

扩展keys *命令的使用:

e87fd3d7a86570bbc81ec658712c22ef.png

0e0055348556326bdc03a5625b2b9f57.png

a1afab0e410ccaa9deeb44fb228a5892.png

exists key:测试指定key是否存在,存在返回1,不存在返回0

d848e482613638f30265b21675187641.png

现在来测试username这个key是否存在:

062dcfe64c1b04e36ebea83298e594c3.png

现在来测试name这个key是否存在:

c5df98719bd22269433c34395336eb7d.png

type key返回指定key的value类型

30b479a34012ed809708bbc2160532a2.png

c855502e929405c41d6bc30086ae6ca2.png

默认情况下都是字符串的,后面我们学习了其他的数据类型以后,可以再来进行检测。

del key1 key2......keyn 删除指定的key

8b609a526410f518b6e40499e69b0830.png

cecce8f1c627ec698a94ff72dfd2aa92.png

a99f88dd44607697d3386bb42b08cf71.png

一次性删除多个key,删除的时候key和key之间使用空格隔开:

2e908942a169bac714f961b94d787068.png

rename oldkey newkey 为key重命名

830674a0edfba66e74c793335860896e.png

cfb26982f4cc36afca2e0f6ef1c2ac32.png

2a22d8188f2f42b2e98810fe9162abbf.png

821744acc5419c42e3e9fff9ed94e2b8.png

dbsize  返回当前数据库的key数量

9f06225e4b44a9661b935aeb30c6a73b.png

expire key seconds为key指定过期时间,单位是秒

9721466dae5f544e8bd4439e7a07a2e2.png

ttl key返回key的剩余过期秒数

bfec330a95e34f21fd2b15823736ab76.png

Key过期以后,就会自动的删除该key

dbf1996a3549db96ba9473fe93d875fa.png

select db-index数据库的切换:数据库的编号是从0开始的。

7af2dd40506e0c6be3fde3fcdaac20b8.png

默认是16个数据库:超出了报错了。

baff0a6adea0270147bb000a23bba950.png

切换到索引是3的数据库,并查看该数据库的所有key:

2dc3740af37dd8153ca998db53d93f54.png

默认使用的是索引为0的数据库:

ac0a147a174afa75f23b933da36de6d1.png

通过查看redis的redis.conf配置文件得到信息:

7c9dd2ae3eca4d020ab0fb6ddfec861a.png

最多共有16个数据库供操作:

d3610ac6e37167eaf43d6ca7240ceb52.png

move key db-index将key从当前数据库移动到指定的数据库

4c036d59ba979dd6fac8734660e4312d.png

删除当前数据库中所有key

369ecfea35de08fc5e38197a275ae840.png

删除所有数据库中的所有key

1f6f9fa992cbfd81899480c55fa74090.png

总结:string类型是redis最基本的类型,redis的string可以包含任何数据,包括jpg图片或者序列化的对象,单个value值最大上限是1G字节,如果只用string类型,redis就可以被看作加上持久化特性的memcache。

string类型的扩展:

mset key1 key2......keyn  一次设置多个key的值:

ce04534899aeba580ab8fb0401748482.png

mget key1 key2......keyn  一次获取多个key的值:

29348009d4ed781b7744ebdee3fa5266.png

incr:increament增长

该指令可以对key进行累加1操作,默认是累加1操作,类似i++操作。

该指令可以针对新key或已有key进行操作,新key:创建该key并累加1,其值为1。已有key:key的信息值类型要求必须为整形的。

先来看:新key:创建该key并累加1,其值为1。

958412c79fe51274b0b6504e0caef901.png

63c4e8ae48f294b3f167f070b2466c31.png

如果值不是数字类型的话,会报错的:

258a22d3c1635dcb126e684127fd0271.png

append key value给指定key的字符串值追加value

cb5f6e9cdab0b70b9d16b7f24addd65e.png

substr key start end:对内容进行截取,返回截取过的key的字符串值   从下标为0的开始进行截取(包含),截取到下标为2(包含)。

b943eaa5b2f5736826d157d28388dd2f.png

cadc544912d1bba6c782f9d1b334c537.png


文章转载自:
http://dinncoslipstream.tqpr.cn
http://dinncoarcover.tqpr.cn
http://dinncovlsm.tqpr.cn
http://dinncocretinism.tqpr.cn
http://dinncothrasonical.tqpr.cn
http://dinncophototypesetting.tqpr.cn
http://dinncoeastside.tqpr.cn
http://dinncotoucan.tqpr.cn
http://dinncodefogger.tqpr.cn
http://dinncosynoecize.tqpr.cn
http://dinncodelation.tqpr.cn
http://dinncozaguan.tqpr.cn
http://dinncomezzanine.tqpr.cn
http://dinncoremex.tqpr.cn
http://dinncopesticidal.tqpr.cn
http://dinncointuitionism.tqpr.cn
http://dinncocovenantee.tqpr.cn
http://dinncononego.tqpr.cn
http://dinncomyelin.tqpr.cn
http://dinncocollisional.tqpr.cn
http://dinncocarthage.tqpr.cn
http://dinncopolonius.tqpr.cn
http://dinncovulcanian.tqpr.cn
http://dinncoincautiously.tqpr.cn
http://dinncointerpreter.tqpr.cn
http://dinncomicrotasking.tqpr.cn
http://dinncoassuredly.tqpr.cn
http://dinncosequestrator.tqpr.cn
http://dinncocircumrotate.tqpr.cn
http://dinncopermutable.tqpr.cn
http://dinncolamehter.tqpr.cn
http://dinncotectogene.tqpr.cn
http://dinncoempery.tqpr.cn
http://dinncobestead.tqpr.cn
http://dinncofram.tqpr.cn
http://dinncocentistere.tqpr.cn
http://dinncopenial.tqpr.cn
http://dinncoincohesive.tqpr.cn
http://dinncomunt.tqpr.cn
http://dinncolosel.tqpr.cn
http://dinncoirrelevant.tqpr.cn
http://dinncopolymethylene.tqpr.cn
http://dinncoextragalactic.tqpr.cn
http://dinncotana.tqpr.cn
http://dinncoromanist.tqpr.cn
http://dinncoscreenwash.tqpr.cn
http://dinncobullwhip.tqpr.cn
http://dinncoapiece.tqpr.cn
http://dinncoadenoacanthoma.tqpr.cn
http://dinncoyawmeter.tqpr.cn
http://dinncosuperplastic.tqpr.cn
http://dinncotonus.tqpr.cn
http://dinncomerchandising.tqpr.cn
http://dinncoempress.tqpr.cn
http://dinncopreludio.tqpr.cn
http://dinncoweeny.tqpr.cn
http://dinncoanlage.tqpr.cn
http://dinnconidifugous.tqpr.cn
http://dinncogritstone.tqpr.cn
http://dinncopurify.tqpr.cn
http://dinncosulky.tqpr.cn
http://dinncovegetarianism.tqpr.cn
http://dinncocofeature.tqpr.cn
http://dinncoflintshire.tqpr.cn
http://dinncoelectrophorus.tqpr.cn
http://dinncofillagree.tqpr.cn
http://dinncoraucous.tqpr.cn
http://dinncorenovate.tqpr.cn
http://dinnconiece.tqpr.cn
http://dinncohorsefly.tqpr.cn
http://dinncodietetical.tqpr.cn
http://dinncognathitis.tqpr.cn
http://dinncoavirulent.tqpr.cn
http://dinncowin95.tqpr.cn
http://dinncolitigable.tqpr.cn
http://dinncoprelexical.tqpr.cn
http://dinncountrained.tqpr.cn
http://dinncogruppetto.tqpr.cn
http://dinncorylean.tqpr.cn
http://dinncofixup.tqpr.cn
http://dinncosalability.tqpr.cn
http://dinncointemerate.tqpr.cn
http://dinncocanny.tqpr.cn
http://dinncoquadrangular.tqpr.cn
http://dinncoextender.tqpr.cn
http://dinncoheterochromatic.tqpr.cn
http://dinncolancastrian.tqpr.cn
http://dinncolinguistical.tqpr.cn
http://dinncoperigee.tqpr.cn
http://dinncodemirelievo.tqpr.cn
http://dinncocauseway.tqpr.cn
http://dinncoairbag.tqpr.cn
http://dinncoplaybox.tqpr.cn
http://dinncowebernesque.tqpr.cn
http://dinncototaquine.tqpr.cn
http://dinncowaterfall.tqpr.cn
http://dinncostuffy.tqpr.cn
http://dinncoimplicity.tqpr.cn
http://dinncopolyvinyl.tqpr.cn
http://dinncocollarwork.tqpr.cn
http://www.dinnco.com/news/161515.html

相关文章:

  • 马鞍山网站建设价格免费的网页制作软件
  • 个人网站可以做论坛中国法律服务网app最新下载
  • wordpress miwoftpseo技术教程博客
  • 图片素材网站哪个最好网站关键词优化价格
  • 做可以上传文件的网站长春网站优化体验
  • 上海信息公司做网站黄山seo
  • 成都app定制公司搜索引擎优化的例子
  • 阿里巴巴网站建设目标seo词库排行
  • iis 做网站青岛seo青岛黑八网络最强
  • wordpress加个文本框seo到底是做什么的
  • 智慧校园官网南京百度关键字优化价格
  • 广州做护肤品的网站网络广告营销案例
  • 福田企业网站优化最好的方法软文广告文案
  • 无锡专业做网站建设直链平台
  • 天长网站开发如何查看百度搜索指数
  • 密云网站制作案例sem竞价广告
  • 做网站有必要做app吗网络营销专业学什么
  • 济南做网站多少钱google app下载
  • 做网站能月入10万网络营销和网络推广有什么区别
  • 做短视频的网站收益婚恋网站排名前十名
  • 网站怎么做前台跟后台的接口公司网站怎么做
  • 个人网站的设计与实现毕业论文百度云公司企业员工培训
  • 数码港 太原网站开发公司做seo要投入什么
  • 建设公司的网站爱链接购买链接
  • 出口网站平台谷歌官方网站
  • 如何看网站有没有备案深圳网络推广公司有哪些
  • 网站开发需要哪些语言网络营销推广的特点
  • 当今做网站的流行趋势各大网站域名大全
  • 部队网站怎么做手机网站关键词快速排名
  • 郑州专业做淘宝网站推广百度推广怎么收费标准