自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

小羽毛的博客

ITer Article

  • 博客(37)
  • 收藏
  • 关注

原创 redis源码分析之config.c

typedef struct configEnum { const char *name; const int val;} configEnum;configEnum maxmemory_policy_enum[] = { {"volatile-lru", MAXMEMORY_VOLATILE_LRU}, {"volatile-lfu", MAXMEMORY_...

2019-06-24 10:40:56 24846

原创 redis源码分析之networking.c

#include "server.h"#include "atomicvar.h"#include <sys/uio.h>#include <math.h>#include <ctype.h>static void setProtocolError(const char *errstr, client *c, int pos);/* Return...

2019-06-24 10:39:37 1243

原创 redis源码分析之anet.c

#include "fmacros.h"#include <sys/types.h>#include <sys/socket.h>#include <sys/stat.h>#include <sys/un.h>#include <sys/time.h>#include <netinet/in.h>#includ...

2019-06-24 10:38:24 634

原创 淘宝天猫系爬虫

淘宝天猫系爬虫github: https://github.com/524243642/mall_spider搞了一段时间Python,独立solo了一套淘宝系服务爬虫有一些问题还是没有很好的解决,有兴趣的朋友可以联系楼主,共同学习!!!主要的业务框架和readme都已经集成在工程中了,Talk is cheap,直接阅读工程吧QQ: 524243642@qq.com...

2019-05-30 19:34:18 1446

原创 redis源码读后感

终于读完redis的源码了,颇有感触。由于互联网公司整体工作结构比较快,平时零零散散的抽出一些时间来阅读,所以前后持续了一段时间(2018-08-21-2019-05-22),关键是做爱做的事情才能坚持下去其中数据结构部分、IO模型部分、以及策略、AOF、RDB,PSYNC部分为精读,其他架构设计部分,redis cluster,redis sentinel部分泛读。也来谈谈一部分感受吧。...

2019-05-22 15:41:41 219

原创 redis源码分析之evict.c

#include "server.h"#include "bio.h"#include "atomicvar.h"/* ---------------------------------------------------------------------------- * Data structures * -------------------------------------...

2019-05-22 15:08:24 763

原创 redis源码分析之object.c

#include "server.h"#include <math.h>#include <ctype.h>#ifdef __CYGWIN__#define strtold(a,b) ((long double)strtod((a),(b)))#endif/* ===================== Creation and parsing of obj...

2019-05-21 19:53:48 265

原创 redis源码分析之server.h

#ifndef __REDIS_H#define __REDIS_H#include "fmacros.h"#include "config.h"#include "solarisfixes.h"#include "rio.h"#include <stdio.h>#include <stdlib.h>#include <string.h>#...

2019-05-21 19:52:23 911 2

原创 redis源码分析之sever.c

#include "server.h"#include "cluster.h"#include "slowlog.h"#include "bio.h"#include "latency.h"#include "atomicvar.h"#include <time.h>#include <signal.h>#include <sys/wait.h&gt...

2019-05-21 19:51:28 888

原创 redis源码分析之replication.c

#include "server.h"#include <sys/time.h>#include <unistd.h>#include <fcntl.h>#include <sys/socket.h>#include <sys/stat.h>void replicationDiscardCachedMaster(void)...

2019-05-21 19:49:43 613

原创 redis源码分析之aof.c

#include "server.h"#include "bio.h"#include "rio.h"#include <signal.h>#include <fcntl.h>#include <sys/stat.h>#include <sys/types.h>#include <sys/time.h>#include ...

2019-05-21 19:47:15 415

原创 redis源码分析之bio.c

#include "server.h"#include "bio.h"static pthread_t bio_threads[BIO_NUM_OPS];static pthread_mutex_t bio_mutex[BIO_NUM_OPS];static pthread_cond_t bio_newjob_cond[BIO_NUM_OPS];static pthread_cond_...

2019-05-21 19:45:36 394

原创 redis源码分析之ae_epoll.c

#include &lt;sys/epoll.h&gt;typedef struct aeApiState { //epoll 监听fd int epfd; //epoll wait产生的事件列表 struct epoll_event *events;} aeApiState;/** * 创建epoll * @param eventLoop * @r...

2019-01-24 17:32:53 402

原创 redis源码分析之ae_select.c

#include &lt;sys/select.h&gt;#include &lt;string.h&gt;/** * select事件结构体 */typedef struct aeApiState { //读事件,写事件分离 fd_set rfds, wfds; //在select方法调用后,不能保证rfds或者wfds的数据是一致的(因为select之后获取...

2019-01-24 17:31:16 325

原创 redis源码分析之ae.c

#include &lt;stdio.h&gt;#include &lt;sys/time.h&gt;#include &lt;sys/types.h&gt;#include &lt;unistd.h&gt;#include &lt;stdlib.h&gt;#include &lt;poll.h&gt;#include &lt;string.h&gt;#include &lt

2019-01-24 17:30:11 416

原创 redis源码分析之ae.h

#ifndef __AE_H__#define __AE_H__#include &lt;time.h&gt;#define AE_OK 0#define AE_ERR -1//文件事件掩码#define AE_NONE 0#define AE_READABLE 1#define AE_WRITABLE 2#define AE_FILE_EVENTS 1#define ...

2019-01-24 17:29:04 447

原创 python skiplist(跳表) high-performance(跳跃表参考redis zset,score可重复)

第一次在PyPi上传开源工程,各种问题搞的相当坎坷,先贴个github地址github: https://github.com/524243642/ratelPyPi:https://pypi.org/project/ratel/本工程参考redis的开源工程(redis源代码十分优秀)编写这个库的缘由是我在编写一个工程化的策略的模块的时候碰到一个棘手的问题,先来描述一下我碰到的问题数据...

2018-11-26 14:41:12 645

转载 搞懂“分布式锁”

https://www.toutiao.com/a6611354991913337347/

2018-11-13 15:44:24 119

原创 redis源码分析系列读者声明

本分析是基于redis4.0.2做的源代码分析;由于博主工作中是用的mac,所以用的mac clion来阅读c代码,原生redis代码并不支持clion,博主是fork了一个github上与clion集成的一个版本;近期准备开redis github的一个注释版,虽然有好多大神已经有好多redis的github的注释版,但是毕竟不如自己亲手去做一次;do better,live bette...

2018-09-29 15:59:16 188

原创 redis源码分析之skiplist(t_zset.c,server.h)

server.h中zskiplist定义/* Objects encoding. Some kind of objects like Strings and Hashes can be * internally represented in multiple ways. The 'encoding' field of the object * is set to one of this fi...

2018-09-29 14:52:57 282

原创 redis源码分析之zipmap.c

/** * 创建空zipmap * @return *//* Create a new empty zipmap. */unsigned char *zipmapNew(void) { unsigned char *zm = zmalloc(2); zm[0] = 0; /* Length */ zm[1] = ZIPMAP_END; return zm...

2018-09-26 16:24:36 209

原创 redis源码分析之zipmap.h

#ifndef _ZIPMAP_H#define _ZIPMAP_H//zipmap相关apiunsigned char *zipmapNew(void);unsigned char *zipmapSet(unsigned char *zm, unsigned char *key, unsigned int klen, unsigned char *val, unsigned int v...

2018-09-26 16:23:16 90

原创 redis源码分析之intset.c

#include &amp;lt;stdio.h&amp;gt;#include &amp;lt;stdlib.h&amp;gt;#include &amp;lt;string.h&amp;gt;#include &quot;intset.h&quot;#include &quot;zmalloc.h&quot;#include &quot;endianconv.h&quot;/* N

2018-09-25 20:03:11 122

原创 redis源码分析之intset.h

#ifndef __INTSET_H#define __INTSET_H#include &amp;lt;stdint.h&amp;gt;/** * intset结构体,编码,元素个数,连续内存的数组 */typedef struct intset { uint32_t encoding; uint32_t length; int8_t contents[];} intse...

2018-09-25 20:02:04 113

转载 redis源码分析之endianconv.c

redis大小端可参考文章https://blog.csdn.net/arkblue/article/details/77531856

2018-09-21 17:21:22 211

原创 redis源码解析之quicklist.c

/* quicklist.c - A doubly linked list of ziplists * * Copyright (c) 2014, Matt Stancliff &amp;amp;lt;matt@genges.com&amp;amp;gt; * All rights reserved. * * Redistribution and use in source and binary forms, with...

2018-09-20 19:46:41 395

原创 redis源码解析之quicklist.h

/* quicklist.h - A generic doubly linked quicklist implementation * * Copyright (c) 2014, Matt Stancliff &amp;amp;amp;lt;matt@genges.com&amp;amp;amp;gt; * All rights reserved. * * Redistribution and use in source and bi...

2018-09-20 19:44:28 259

原创 redis源码分析感想

首先和阅读文章的朋友先道个歉,因为直接贴源码的关系,被小伙伴的有些吐槽,在这里解释一下。 因为redis的源码本身的量并不是很大,但是有些设计比较精妙,比如著名的map里的渐进式rehash和遍历map的bit reverse算法,需要详细阅读代码才能理解其意义,我没有很多时间去整理相关的图来做通俗的解释,我会引用一些别人的csdn文章来直接做为引用。但是别人的文章,我首先会认真阅读其中的内容(...

2018-09-10 15:33:39 675

原创 redis源码解析之ziplist.c

#include &amp;amp;lt;stdio.h&amp;amp;gt;#include &amp;amp;lt;stdlib.h&amp;amp;gt;#include &amp;amp;lt;string.h&amp;amp;gt;#include &amp;amp;lt;stdint.h&amp;amp;gt;#include &amp;amp;lt;limits.h&amp;amp;gt;#i

2018-09-10 15:14:40 302

原创 redis源码解析之ziplist.h

#ifndef _ZIPLIST_H#define _ZIPLIST_H#define ZIPLIST_HEAD 0#define ZIPLIST_TAIL 1unsigned char *ziplistNew(void);//新建ziplistunsigned char *ziplistMerge(unsigned char **first, unsigned char **sec...

2018-09-10 15:12:56 128

原创 redis源码解析之dict.c

#include &quot;fmacros.h&quot;#include &amp;lt;stdio.h&amp;gt;#include &amp;lt;stdlib.h&amp;gt;#include &amp;lt;stdint.h&amp;gt;#include &amp;lt;string.h&amp;gt;#include &amp;lt;stdarg.h&amp;gt;

2018-09-04 17:54:48 497

原创 redis源码解析之dict.h

#include &amp;lt;stdint.h&amp;gt;#ifndef __DICT_H#define __DICT_H#define DICT_OK 0#define DICT_ERR 1/* Unused arguments generate annoying warnings... */#define DICT_NOTUSED(V) ((void) V)typedef str...

2018-09-04 17:51:45 1142 2

原创 redis源码解析之adlist.c

#include &amp;lt;stdlib.h&amp;gt;#include &quot;adlist.h&quot;#include &quot;zmalloc.h&quot;/** * 创建list并做初始化 * @return *//* Create a new list. The created list can be freed with * AlFreeList(), but private value o

2018-08-22 16:38:10 198

原创 redis源码解析之adlist.h

#ifndef __ADLIST_H__#define __ADLIST_H__/* Node, List, and Iterator are the only data structures used currently. */typedef struct listNode { struct listNode *prev; struct listNode *next;...

2018-08-22 16:36:45 180

原创 redis源码解析之sds.c

#include &amp;amp;lt;stdio.h&amp;amp;gt;#include &amp;amp;lt;stdlib.h&amp;amp;gt;#include &amp;amp;lt;string.h&amp;amp;gt;#include &amp;amp;lt;ctype.h&amp;amp;gt;#include &amp;amp;lt;assert.h&amp;amp;gt;#in

2018-08-21 19:22:07 646

原创 redis源码解析之sds.h

#ifndef __SDS_H#define __SDS_H#define SDS_MAX_PREALLOC (1024*1024)#include &amp;amp;lt;sys/types.h&amp;amp;gt;#include &amp;amp;lt;stdarg.h&amp;amp;gt;#include &amp;amp;lt;stdint.h&amp;amp;gt;typedef char *sds;

2018-08-21 19:21:09 966

原创 前言

毕业刚好满两年了,业务部门出身,之前待的业务做票务相关,由于业务比较特殊,加上运气也比较好,自己对技术也比较有兴趣,也就马马虎虎的学习了一些东西。 之前的业务由于是做主动式高并发业务,所以需要一些底层服务去支撑高并发流量,所以自然就对redis这种nosql中间件的应用特别熟悉。俗话说用一个东西要先知其然而后知其所以然,之前零零星星的看过一些redis的源代码,也只是为了面试草草的看了一些,现在...

2018-08-21 19:14:28 118

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除