├── .gitattributes ├── README.md ├── RedisDemo ├── Client.cpp ├── Server.cpp ├── myRedis.h ├── myRedis_BTreeAndHash.h └── server_BTreeAndHash.cpp └── RedisDemo2.0 ├── Client.cpp └── server ├── adlist.cpp ├── adlist.h ├── dict.cpp ├── dict.h ├── hashTableTest.cpp ├── redisClient.h ├── redisDb.cpp ├── redisDb.h ├── redisServer.h ├── sds.cpp ├── sds.h └── serverAndClientTest.cpp /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cpp_Redis 2 | 3 | 实现详情请查看[我的文章](https://segmentfault.com/a/1190000018215657) 4 | 5 | 项目现在实现了客户端与服务器的链接与交互,以及一些Redis的基本命令,下面是测试结果: 6 | 7 | (左边是服务端,右边是客户端) 8 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/20190220112757211.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQwOTU1Mjg3,size_16,color_FFFFFF,t_70) 9 | 10 | 为了完善其功能并且锻炼一下自己的数据结构与算法,我下一阶段打算根据[《Redis设计与实现》](http://redisbook.com/)一书优化数据结构与算法从而完善自己的项目。 11 | 12 |

13 | 14 | ## 基本流程介绍 15 | 首先是对服务端的初始化,包括数据库的初始化以及命令集合的初始化。 16 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/20190220113202156.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQwOTU1Mjg3,size_16,color_FFFFFF,t_70) 17 |
18 | 19 | 在客户端连接之后,开始创建客户端对其进行初始化,并且将其与服务端对应的数据库进行连接。 20 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/20190220113217410.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQwOTU1Mjg3,size_16,color_FFFFFF,t_70) 21 |
22 | 23 | 在客户端发送命令之后,服务端接受命令,对命令的合法性进行判断,然后在命令集合中查找相关命令并执行,最后返回执行结果给客户端。 24 | 25 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/20190220113230102.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQwOTU1Mjg3,size_16,color_FFFFFF,t_70) 26 | 27 |

28 | -------------------------------------------------------------------------------- /RedisDemo/Client.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShimmerPig/cpp_Redis/1a75f47fd850d1a2c0331d9d035b477fe5838d14/RedisDemo/Client.cpp -------------------------------------------------------------------------------- /RedisDemo/Server.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShimmerPig/cpp_Redis/1a75f47fd850d1a2c0331d9d035b477fe5838d14/RedisDemo/Server.cpp -------------------------------------------------------------------------------- /RedisDemo/myRedis.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShimmerPig/cpp_Redis/1a75f47fd850d1a2c0331d9d035b477fe5838d14/RedisDemo/myRedis.h -------------------------------------------------------------------------------- /RedisDemo/myRedis_BTreeAndHash.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShimmerPig/cpp_Redis/1a75f47fd850d1a2c0331d9d035b477fe5838d14/RedisDemo/myRedis_BTreeAndHash.h -------------------------------------------------------------------------------- /RedisDemo/server_BTreeAndHash.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShimmerPig/cpp_Redis/1a75f47fd850d1a2c0331d9d035b477fe5838d14/RedisDemo/server_BTreeAndHash.cpp -------------------------------------------------------------------------------- /RedisDemo2.0/Client.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShimmerPig/cpp_Redis/1a75f47fd850d1a2c0331d9d035b477fe5838d14/RedisDemo2.0/Client.cpp -------------------------------------------------------------------------------- /RedisDemo2.0/server/adlist.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShimmerPig/cpp_Redis/1a75f47fd850d1a2c0331d9d035b477fe5838d14/RedisDemo2.0/server/adlist.cpp -------------------------------------------------------------------------------- /RedisDemo2.0/server/adlist.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShimmerPig/cpp_Redis/1a75f47fd850d1a2c0331d9d035b477fe5838d14/RedisDemo2.0/server/adlist.h -------------------------------------------------------------------------------- /RedisDemo2.0/server/dict.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShimmerPig/cpp_Redis/1a75f47fd850d1a2c0331d9d035b477fe5838d14/RedisDemo2.0/server/dict.cpp -------------------------------------------------------------------------------- /RedisDemo2.0/server/dict.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShimmerPig/cpp_Redis/1a75f47fd850d1a2c0331d9d035b477fe5838d14/RedisDemo2.0/server/dict.h -------------------------------------------------------------------------------- /RedisDemo2.0/server/hashTableTest.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShimmerPig/cpp_Redis/1a75f47fd850d1a2c0331d9d035b477fe5838d14/RedisDemo2.0/server/hashTableTest.cpp -------------------------------------------------------------------------------- /RedisDemo2.0/server/redisClient.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShimmerPig/cpp_Redis/1a75f47fd850d1a2c0331d9d035b477fe5838d14/RedisDemo2.0/server/redisClient.h -------------------------------------------------------------------------------- /RedisDemo2.0/server/redisDb.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShimmerPig/cpp_Redis/1a75f47fd850d1a2c0331d9d035b477fe5838d14/RedisDemo2.0/server/redisDb.cpp -------------------------------------------------------------------------------- /RedisDemo2.0/server/redisDb.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShimmerPig/cpp_Redis/1a75f47fd850d1a2c0331d9d035b477fe5838d14/RedisDemo2.0/server/redisDb.h -------------------------------------------------------------------------------- /RedisDemo2.0/server/redisServer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShimmerPig/cpp_Redis/1a75f47fd850d1a2c0331d9d035b477fe5838d14/RedisDemo2.0/server/redisServer.h -------------------------------------------------------------------------------- /RedisDemo2.0/server/sds.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShimmerPig/cpp_Redis/1a75f47fd850d1a2c0331d9d035b477fe5838d14/RedisDemo2.0/server/sds.cpp -------------------------------------------------------------------------------- /RedisDemo2.0/server/sds.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShimmerPig/cpp_Redis/1a75f47fd850d1a2c0331d9d035b477fe5838d14/RedisDemo2.0/server/sds.h -------------------------------------------------------------------------------- /RedisDemo2.0/server/serverAndClientTest.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShimmerPig/cpp_Redis/1a75f47fd850d1a2c0331d9d035b477fe5838d14/RedisDemo2.0/server/serverAndClientTest.cpp --------------------------------------------------------------------------------