redis source code analysis

Read about redis source code analysis, The latest news, videos, and discussion topics about redis source code analysis from

Redis source code analysis (1) -- redis Structure Analysis

From today on, I will start learning redis source code. The redis code is relatively small and very suitable for learning. It is a very good learning material, it looks like about 100 files, which are written in C language. I hope I can finally get rid of him. I don't need t

Redis Source Code Analysis (34) --- implementation analysis of the redis. h server (1)

原型方法*/Four major modules 1.ReferenceHeader file Declaration 2. macro definition variable definition 3. Data Structure Declaration 4. Method prototype Declaration It is particularly pointed out that the structure definitions of redisobject, redisclient, and redisserver appearing everywhere in the Code are defined in this file. /* The actual Redis Object */#define REDIS_LRU_BITS 24#define REDIS_LRU_CLO

Redis Source Code Analysis (35) --- implementation analysis of redis. c server (2)

... "); exit (1);} If (configfile) server. configfile = getabsolutepath (configfile); resetserversaveparams (); // load server configurations, load loadserverconfig (configfile, options) according to the config configuration file; sdsfree (options );} else {redislog (redis_warning, "Warning: No config file specified, using The default config. In order to specify a Config File use % S/path/to/% S. conf ", argv [0], server. sentinel_mode? "Sentinel": "redis

Redis Source Code Analysis () --- Redis's 11 excellent designs

the position pattern ++; patternLen --; if (pattern [0] = string [0]) match = 1;} else if (pattern [0] = ']') {// stop break until another brackets exist.} else if (patternLen = 0) {pat Tern --; patternLen ++; break;} else if (pattern [1] = '-' patternLen> = 3) {int start = pattern [0]; int end = pattern [2]; int c = string [0]; if (start> end) {int t = start; start = end; end = t ;} if (nocase) {start = tolower (start); end = tolower (end); c = tolower (c);} pattern + = 2; pat

Redis source code analysis () --- redis-cli.c client command line interface implementation (1)

* types, unsigned long * sizes) Static void findbigkeys (void)/* stats mode */static char * getinfofield (char * info, char * field) Static long getlonginfofield (char * info, char * field) void bytestohuman (char * s, long n) Static void statmode (void)/* scan mode */static void scanmode (void) /* Intrisic latency mode */unsigned long polling (void) Static void intrinsiclatencymodestop (INT s) Static void intrinsiclatencymode (void)/* Program Main () */INT main (INT argc, char ** argv)

Redis source code analysis (1) -- Redis Data Structure-string SDS, redissds

Redis source code analysis (1) -- Redis Data Structure-string SDS, redissds 1. SDS Overview The strings used in Redis are Simple Dynamic strings (SDS. SDS is packaged Based on the C string to make it more suitable for

Redis Source Code Analysis (33) --- implementation of redis-cli.c client command line interface (2)

, set and other frequently used commands, which can be followed by multiple parameter commands, attribute command group commands, generally config get, such a single command is called a common command, Dump, Exist, and so on. There are not many CommandGroup commands as follows:/* All command groups */static char * commandGroups [] = {"generic", "string", "list", "set", "sorted_set", "hash ", "pubsub", "transactions",

Redis Source Code Analysis (iv): REDIS data type hash table, list, collection, and ordered collection

The hash table is also one of the data structures supported by Redis, which uses both redis_encoding_ziplist (compressed list) and redis_encoding_ht (data Dictionary) encoding methods.When a hash table uses a compressed list, it uses the following structure to store the data (see ZIPLIST.C):+---------+------+------+------+------+------+------+------+------+---------+| ziplist | | | | | | | | | Ziplist | | ENTRY | Key1 | Val1 | Key2 | Val2 | ... | ...

Redis Source Code Analysis (12)---redis-check-dump Local database detection

) {case Redis_string:case redis_hash_zipmap:case REDIS_LIST_ZIPL Ist:case redis_set_intset:case redis_zset_ziplist:case redis_hash_ziplist://Because a struct like ziplist,zipmap is actually a node. Connected to a super string, so is directly read if (!processstringobject (NULL)) {Shift_error (offset, "ERROR reading entry value"); return 0; } break; Case Redis_list:case Redis_set://And the above 2 types are the traditional structure, to divide the node to read for (i = 0; i If the e-

Redis source code analysis () --- latency analysis and processing

object */INT latencyresetevent (char * event_to_reset)/* reset the latency of the event, delete the event record in the dictionary */void analyzelatencyforevent (char * event, struct latencystats * ls)/* analyze the delay result of the event at a certain time, the result information is stored in the latencystats structure */SDS createlatencyreport (void)/*. Based on the results of the delayed sample, the analysis report with good readability is creat

Redis source code analysis 23-VM (on)

"); } server.vm_bitmap = zmalloc((server.vm_pages+7)/8); redisLog(REDIS_VERBOSE,"Allocated %lld bytes page table for %lld pages", (long long) (server.vm_pages+7)/8, server.vm_pages); memset(server.vm_bitmap,0,(server.vm_pages+7)/8); /* Initialize threaded I/O (used by Virtual Memory) */ server.io_newjobs = listCreate(); server.io_processing = listCreate(); server.io_processed = listCreate(); server.io_ready_clients = listCreate(); pthread_mutex_init(

Redis source code analysis 19-master-slave Replication

]->ptr,"no") !strcasecmp(c->argv[2]->ptr,"one")) { if (server.masterhost) { sdsfree(server.masterhost); server.masterhost = NULL; if (server.master) freeClient(server.master); server.replstate = REDIS_REPL_NONE; redisLog(REDIS_NOTICE,"MASTER MODE enabled (user request)"); } } else { sdsfree(server.masterhost); server.masterhost = sdsdup(c->argv[1]->ptr); server.masterport = atoi(c->argv[2]->ptr);

Redis Source Code Analysis (1)--initialization

heavy IO operations, such as AoF's Fsync, calls are made by asynchronous threads, avoiding the event loops that block the main thread. The above is the Initserver function. /* Instances limited to 4GB of address space, so if there is * No explicit limit in the user provided CONFI Guration we set a limit * at 3 GB using MaxMemory with ' noeviction ' policy '. This avoids * useless crashes of the Redis instance for out of memory. * *

Redis source code analysis 22-Protocol

*/ } listAddNodeTail(c->reply,getDecodedObject(obj));}static void sendReplyToClient(aeEventLoop *el, int fd, void *privdata, int mask) { redisClient *c = privdata; int nwritten = 0, totwritten = 0, objlen; robj *o; REDIS_NOTUSED(el); REDIS_NOTUSED(mask); /* Use writev() if we have enough buffers to send */ if (!server.glueoutputbuf listLength(c->reply) > REDIS_WRITEV_THRESHOLD !(c->flags REDIS_MASTER)) { sendReplyToClientWritev(el, fd, privd

Redis source code analysis (7) --- zipmap compression Graph

tables, both of which achieve high Memory Operation Efficiency ** Copyright (c) 2009-2010, Salvatore Sanfilippo * All rights reserved. ** Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * ** Redistributions of source code must retain the above copyright notice, * thi

Redis source code analysis (4) -- SDS string

Today, we are analyzing the Code Implementation of the string operation class in the redis source code. With several analysis experiences, I gradually felt that I had to change the analysis method. If every API performs

Redis source code analysis () --- create and release a redisObject object, redisredisobject

Redis source code analysis () --- create and release a redisObject object, redisredisobject Today's learning efficiency is relatively high. After analyzing Rio, I learned the RedisObject file, which is about converting and creating RedisObject. Most of the methods are very similar. List the long API list: /* ---------

Redis source code analysis (19th) --- bio background I/O service implementation

; /* it is now possible to unlock the background system as we know have * a stand alone job structure to process. */pthread_mutex_unlock ( bio_mutex [type]);/* process the job accordingly to its type. * // execute the specific job if (type = redis_bio_close_file) {close (long) Job-> arg1);} else if (type = redis_bio_aof_fsync) {aof_fsync (long) Job-> arg1);} else {redispanic ("wrong job type in bioprocessbackgroundjobs (). ");} zfree (job);/* lock again before reiterating the loop, if there are

Redis source code analysis (30th) --- pubsub publish and subscribe Mode

Redis source code analysis (30th) --- pubsub publish and subscribe Mode Today I learned the term "Publish and subscribe mode" in Redis, which was first introduced to JMS (Java Message Service) java Message Service. I subscribe to these types of messages. Only when these type

Redis Source Code Analysis 1----String SDS

; - Break; + } -}1.2.3 Storage space Pre-allocation  1 SDS Sdsmakeroomfor (SDS s, size_t Addlen) {2 void*sh, *newsh;3size_t avail =Sdsavail (s);4 size_t len, Newlen;5 CharType, Oldtype = s[-1] Sds_type_mask;6 intHdrlen;7 8 /*Return ASAP If there is enough space left.*/9 if(Avail >= Addlen)returns;Ten OneLen =Sdslen (s); ASH = (Char*) ssdshdrsize (oldtype); -Newlen = (len+Addlen); - //if less than Sds_max_prealloc, the new length of the allocation is twic

Total Pages: 15 1 2 3 4 5 .... 15 Go to: Go

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.