A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 大魔王是男生 初级黑马   /  2019-4-5 22:23  /  1201 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文


[size=10.5000pt]<原本想插一首歌的,发现是付费歌曲,添加不了链接,虽然可以破解一下,但是我懒,歌名叫懂了就懂了,不错,可以造一下>
[size=10.5000pt]灯光再亮,也有熄灭的时候,在角落唱歌,蔓延的孤独和无措,是一个即将毕业的人,那个人可以说是我,也可以说是广大毕业生。
[size=10.5000pt]18年的暑假我去了北京,人生第一次受到学历的冲击,参加中国学联的会议,让我不再以前那般骄傲,晚上围坐着玩狼人杀局的伙伴都是985211的青年才俊,我们虽然都有同一个身份,各省份的优秀高校KAB俱乐部主席代表,但是我们知道我们彼此的差距,那便是所在的高校。未来不超过两年,我们可能就是不同世界的人。
[size=10.5000pt]从那以后我就开始失眠了,我们这个Java班很多人都说自己有失眠,我想都是压力造成的吧。那些夜晚还有那些白日我都在想我以后该做什么,喧嚣世界我学会了什么,有时候外表坚强,内心却泪流成河。还是希望能留在幼稚的年纪,但是还是忍不住的长大,老师以前教的,懂了可能真的是上了年纪吧,戴着耳机听着流行歌曲也抵挡不住。
[size=10.5000pt]于是我做了一个决定,来黑马进修,家里人反对,我和他们理论了一个月多,最后家人妥协了,但是我不是高兴,有些害怕,是第一次和家人对立,获得了胜利,但是我也不知道自己是不是对的。
[size=10.5000pt]在黑马已经有几个月了,学习到的东西很受用,虽然大学学的专业也是软件开发,但是大学贪玩,没怎么学习,在黑马就等于重新学习一下了。以下是我的感言贴还加了一些技术贴,来黑马上学的第一天是兴奋的,第一天的课程也是激动的。那天上的我都会,所有学的很轻松,接受起来也没有压力。此后学的东西越来越多,渐渐后来所学已经没有印象在大学有学过。此后我学过的数据库还有JS还有web,大学都是学习了一至两个学期,浓缩成几天的课后学习起来还是有些吃力,不过大学有学过有些印象,但是就是仗着学过,学习的时候松懈了,导致有些地方跟不上,到后来慢慢就变成了部分内容听天书一般的感受,这种感觉很不好受。
[size=10.5000pt]以下是我最近一天学习的内容笔记,是我删选修改后的。
[size=10.5000pt]Redisredis是一款高性能的NOSQL系列的非关系型数据库
[size=10.5000pt]NoSQL(NoSQL = Not Only SQL),意即“不仅仅是SQL”,是一项全新的数据库理念,泛指非关系型的数据库。随着互联网web2.0网站的兴起,传统的关系数据库在应付web2.0网站,特别是超大规模和高并发的SNS类型的web2.0纯动态网站已经显得力不从心,暴露了很多难以克服的问题,而非关系型的数据库则由于其本身的特点得到了非常迅速的发展。NoSQL数据库的产生就是为了解决大规模数据集合多重数据种类带来的挑战,尤其是大数据应用难题。
[size=10.5000pt]NOSQL和关系型数据库比较
[size=10.5000pt]优点:成本:nosql数据库简单易部署,基本都是开源软件,不需要像使用oracle那样花费大量成本购买使用,相比关系型数据库价格便宜。查询速度:nosql数据库将数据存储于缓存之中,关系型数据库将数据存储在硬盘中,自然查询速度远不及nosql数据库。存储数据的格式:nosql的存储格式是key,value形式、文档形式、图片形式等等,所以可以存储基础类型以及对象或者是集合等各种格式,而数据库则只支持基础类型。扩展性:关系型数据库有类似join这样的多表查询机制的限制导致扩展很艰难。
[size=10.5000pt]缺点:维护的工具和资料有限,因为nosql是属于新的技术,不能和关系型数据库10几年的技术同日而语。不提供对sql的支持,如果不支持sql这样的工业标准,将产生一定用户的学习和使用成本。不提供关系型数据库对事务的处理。
[size=10.5000pt]非关系型数据库的优势:性能NOSQL是基于键值对的,可以想象成表中的主键和值的对应关系,而且不需要经过SQL层的解析,所以性能非常高。可扩展性同样也是因为基于键值对,数据之间没有耦合性,所以非常容易水平扩展。
[size=10.5000pt]关系型数据库的优势:复杂查询可以用SQL语句方便的在一个表以及多个表之间做非常复杂的数据查询。事务支持使得对于安全性能很高的数据访问要求得以实现。对于这两类数据库,对方的优势就是自己的弱势,反之亦然。
[size=10.5000pt]总结:关系型数据库与NoSQL数据库并非对立而是互补的关系,即通常情况下使用关系型数据库,在适合使用NoSQL的时候使用NoSQL数据库,让NoSQL数据库对关系型数据库的不足进行弥补。一般会将数据存储在关系型数据库中,在nosql数据库中备份存储关系型数据库的数据
[size=10.5000pt]劣势:需要对整个图做计算才能得出结果,不容易做分布式的集群方案。
[size=10.5000pt] 命令操作
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]1. 字符串类型 string
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]1. 存储: set key value
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]127.0.0.1:6379> set username zhangsan
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]OK
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]2. 获取: get key
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]127.0.0.1:6379> get username
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]"zhangsan"
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]3. 删除: del key
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]127.0.0.1:6379> del age
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt](integer) 1
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]2. 哈希类型 hash
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]1. 存储: hset key field value
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]127.0.0.1:6379> hset myhash username lisi
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt](integer) 1
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]127.0.0.1:6379> hset myhash password 123
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt](integer) 1
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]2. 获取:
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]* hget key field: 获取指定的field对应的值
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]127.0.0.1:6379> hget myhash username
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]"lisi"
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]* hgetall key:获取所有的fieldvalue
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]127.0.0.1:6379> hgetall myhash
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]1) "username"
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]2) "lisi"
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]3) "password"
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]4) "123"
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]       
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]3. 删除: hdel key field
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]127.0.0.1:6379> hdel myhash username
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt](integer) 1
[size=10.5000pt]    [size=10.5000pt]       
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]3. 列表类型 list:可以添加一个元素到列表的头部(左边)或者尾部(右边)
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]1. 添加:
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]1. lpush key value: 将元素加入列表左表
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]       
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]2. rpush key value:将元素加入列表右边
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]       
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]127.0.0.1:6379> lpush myList a
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt](integer) 1
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]127.0.0.1:6379> lpush myList b
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt](integer) 2
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]127.0.0.1:6379> rpush myList c
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt](integer) 3
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]2. 获取:
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]* lrange key start end :范围获取
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]127.0.0.1:6379> lrange myList 0 -1
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]1) "b"
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]2) "a"
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]3) "c"
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]3. 删除:
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]* lpop key: 删除列表最左边的元素,并将元素返回
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]* rpop key: 删除列表最右边的元素,并将元素返回
[size=10.5000pt]
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]4. 集合类型 set : 不允许重复元素
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]1. 存储:sadd key value
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]127.0.0.1:6379> sadd myset a
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt](integer) 1
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]127.0.0.1:6379> sadd myset a
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt](integer) 0
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]2. 获取:smembers key:获取set集合中所有元素
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]127.0.0.1:6379> smembers myset
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]1) "a"
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]3. 删除:srem key value:删除set集合中的某个元素[size=10.5000pt]       
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]127.0.0.1:6379> srem myset a
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt](integer) 1
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]5. 有序集合类型 sortedset:不允许重复元素,且元素有顺序.每个元素都会关联一个double类型的分数。redis正是通过分数来为集合中的成员进行从小到大的排序。
[size=10.5000pt]   
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]1. 存储:zadd key score value
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]127.0.0.1:6379> zadd mysort 60 zhangsan
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt](integer) 1
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]127.0.0.1:6379> zadd mysort 50 lisi
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt](integer) 1
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]127.0.0.1:6379> zadd mysort 80 wangwu
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt](integer) 1
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]2. 获取:zrange key start end [withscores]
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]127.0.0.1:6379> zrange mysort 0 -1
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]1) "lisi"
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]2) "zhangsan"
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]3) "wangwu"
[size=10.5000pt]   
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]127.0.0.1:6379> zrange mysort 0 -1 withscores
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]1) "zhangsan"
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]2) "60"
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]3) "wangwu"
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]4) "80"
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]5) "lisi"
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]6) "500"
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]3. 删除:zrem key value
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]127.0.0.1:6379> zrem mysort lisi
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt](integer)
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]6. 通用命令
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]1. keys * : 查询所有的键
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]2. type key : 获取键对应的value的类型
[size=10.5000pt]    [size=10.5000pt]        [size=10.5000pt]        [size=10.5000pt]3. del key:删除指定的key value

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马