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

深入刨析Redis存储技术设计艺术(二)

三、Redis主存储

3.1、存储相关结构体

redisServer:服务器

server.h

struct redisServer {   /* General */   pid_t pid;                  /* Main process pid. */   pthread_t main_thread_id;         /* Main thread id */   char *configfile;           /* Absolute config file path, or NULL */   char *executable;           /* Absolute executable file path. */   char **exec_argv;           /* Executable argv vector (copy). */   int dynamic_hz;             /* Change hz value depending on # of clients. */   int config_hz;              /* Configured HZ value. May be different than                                  the actual 'hz' field value if dynamic-hz                                  is enabled. */   mode_t umask;               /* The umask value of the process on startup */   int hz;                     /* serverCron() calls frequency in hertz */   int in_fork_child;          /* indication that this is a fork child */   redisDb *db;   dict *commands;             /* Command table */   dict *orig_commands;        /* Command table before command renaming. */   aeEventLoop *el;   rax *errors;                /* Errors table */   redisAtomic unsigned int lruclock; /* Clock for LRU eviction */   volatile sig_atomic_t shutdown_asap; /* SHUTDOWN needed ASAP */   int activerehashing;        /* Incremental rehash in serverCron() */   int active_defrag_running;  /* Active defragmentation running (holds current scan aggressiveness) */   char *pidfile;              /* PID file path */   int arch_bits;              /* 32 or 64 depending on sizeof(long) */   int cronloops;              /* Number of times the cron function run */   char runid[CONFIG_RUN_ID_SIZE+1];  /* ID always different at every exec. */   int sentinel_mode;          /* True if this instance is a Sentinel. */   size_t initial_memory_usage; /* Bytes used after initialization. */   int always_show_logo;       /* Show logo even for non-stdout logging. */   int in_eval;                /* Are we inside EVAL? */   int in_exec;                /* Are we inside EXEC? */   int propagate_in_transaction;  /* Make sure we don't propagate nested MULTI/EXEC */   char *ignore_warnings;      /* Config: warnings that should be ignored. */   int client_pause_in_transaction; /* Was a client pause executed during this Exec? */   /* Modules */   dict *moduleapi;            /* Exported core APIs dictionary for modules. */   dict *sharedapi;            /* Like moduleapi but containing the APIs that                                  modules share with each other. */   list *loadmodule_queue;     /* List of modules to load at startup. */   int module_blocked_pipe[2]; /* Pipe used to awake the event loop if a                                  client blocked on a module command needs                                  to be processed. */   pid_t child_pid;            /* PID of current child */   int child_type;             /* Type of current child */   client *module_client;      /* "Fake" client to call Redis from modules */   /* Networking */   int port;                   /* TCP listening port */   int tls_port;               /* TLS listening port */   int tcp_backlog;            /* TCP listen() backlog */   char *bindaddr[CONFIG_BINDADDR_MAX]; /* Addresses we should bind to */   int bindaddr_count;         /* Number of addresses in server.bindaddr[] */   char *unixsocket;           /* UNIX socket path */   mode_t unixsocketperm;      /* UNIX socket permission */   socketFds ipfd;             /* TCP socket file descriptors */   socketFds tlsfd;            /* TLS socket file descriptors */   int sofd;                   /* Unix socket file descriptor */   socketFds cfd;              /* Cluster bus listening socket */   list *clients;              /* List of active clients */   list *clients_to_close;     /* Clients to close asynchronously */   list *clients_pending_write; /* There is to write or install handler. */   list *clients_pending_read;  /* Client has pending read socket buffers. */   list *slaves, *monitors;    /* List of slaves and MONITORs */   client *current_client;     /* Current client executing the command. */   rax *clients_timeout_table; /* Radix tree for blocked clients timeouts. */   long fixed_time_expire;     /* If > 0, expire keys against server.mstime. */   rax *clients_index;         /* Active clients dictionary by client ID. */   pause_type client_pause_type;      /* True if clients are currently paused */   list *paused_clients;       /* List of pause clients */   mstime_t client_pause_end_time;    /* Time when we undo clients_paused */   char neterr[ANET_ERR_LEN];   /* Error buffer for anet.c */   dict *migrate_cached_sockets;/* MIGRATE cached sockets */   redisAtomic uint64_t next_client_id; /* Next client unique ID. Incremental. */   int protected_mode;         /* Don't accept external connections. */   int gopher_enabled;         /* If true the server will reply to gopher                                  queries. Will still serve RESP2 queries. */   int io_threads_num;         /* Number of IO threads to use. */   int io_threads_do_reads;    /* Read and parse from IO threads? */   int io_threads_active;      /* Is IO threads currently active? */   long long events_processed_while_blocked; /* processEventsWhileBlocked() */
​   /* RDB / AOF loading information */   volatile sig_atomic_t loading; /* We are loading data from disk if true */   off_t loading_total_bytes;   off_t loading_rdb_used_mem;   off_t loading_loaded_bytes;   time_t loading_start_time;   off_t loading_process_events_interval_bytes;   /* Fast pointers to often looked up command */   struct redisCommand *delCommand, *multiCommand, *lpushCommand,                       *lpopCommand, *rpopCommand, *zpopminCommand,                       *zpopmaxCommand, *sremCommand, *execCommand,                       *expireCommand, *pexpireCommand, *xclaimCommand,                       *xgroupCommand, *rpoplpushCommand, *lmoveCommand;   /* Fields used only for stats */   time_t stat_starttime;          /* Server start time */   long long stat_numcommands;     /* Number of processed commands */   long long stat_numconnections;  /* Number of connections received */   long long stat_expiredkeys;     /* Number of expired keys */   double stat_expired_stale_perc; /* Percentage of keys probably expired */   long long stat_expired_time_cap_reached_count; /* Early expire cylce stops.*/   long long stat_expire_cycle_time_used; /* Cumulative microseconds used. */   long long stat_evictedkeys;     /* Number of evicted keys (maxmemory) */   long long stat_keyspace_hits;   /* Number of successful lookups of keys */   long long stat_keyspace_misses; /* Number of failed lookups of keys */   long long stat_active_defrag_hits;      /* number of allocations moved */   long long stat_active_defrag_misses;    /* number of allocations scanned but not moved */   long long stat_active_defrag_key_hits;  /* number of keys with moved allocations */   long long stat_active_defrag_key_misses;/* number of keys scanned and not moved */   long long stat_active_defrag_scanned;   /* number of dictEntries scanned */   size_t stat_peak_memory;        /* Max used memory record */   long long stat_fork_time;       /* Time needed to perform latest fork() */   double stat_fork_rate;          /* Fork rate in GB/sec. */   long long stat_total_forks;     /* Total count of fork. */   long long stat_rejected_conn;   /* Clients rejected because of maxclients */   long long stat_sync_full;       /* Number of full resyncs with slaves. */   long long stat_sync_partial_ok; /* Number of accepted PSYNC requests. */   long long stat_sync_partial_err;/* Number of unaccepted PSYNC requests. */   list *slowlog;                  /* SLOWLOG list of commands */   long long slowlog_entry_id;     /* SLOWLOG current entry ID */   long long slowlog_log_slower_than; /* SLOWLOG time limit (to get logged) */   unsigned long slowlog_max_len;     /* SLOWLOG max number of items logged */   struct malloc_stats cron_malloc_stats; /* sampled in serverCron(). */   redisAtomic long long stat_net_input_bytes; /* Bytes read from network. */   redisAtomic long long stat_net_output_bytes; /* Bytes written to network. */   size_t stat_current_cow_bytes;  /* Copy on write bytes while child is active. */   monotime stat_current_cow_updated;  /* Last update time of stat_current_cow_bytes */   size_t stat_current_save_keys_processed;  /* Processed keys while child is active. */   size_t stat_current_save_keys_total;  /* Number of keys when child started. */   size_t stat_rdb_cow_bytes;      /* Copy on write bytes during RDB saving. */ 

相关文章:

深入刨析Redis存储技术设计艺术(二)

三、Redis主存储 3.1、存储相关结构体 redisServer:服务器 server.h struct redisServer { /* General */ pid_t pid; /* Main process pid. */ pthread_t main_thread_id; /* Main thread id */ char *configfile; /* Absolut…...

python读取写入txt文本文件

读取 txt 文件 def read_txt_file(file_path):"""读取文本文件的内容:param file_path: 文本文件的路径:return: 文件内容"""try:with open(file_path, r, encodingutf-8) as file:content file.read()return contentexcept FileNotFoundError…...

日期选取限制日期范围antdesign vue

限制选取的日期范围 效果图 <a-date-pickerv-model"dateTime"format"YYYY-MM-DD":disabled-date"disabledDate"valueFormat"YYYY-MM-DD"placeholder"请选择日期"allowClear />methods:{//回放日期选取范围限制&…...

【大模型】衡量巨兽:解读评估LLM性能的关键技术指标

衡量巨兽&#xff1a;解读评估LLM性能的关键技术指标 引言一、困惑度&#xff1a;语言模型的试金石1.1 定义与原理1.2 计算公式1.3 应用与意义 二、BLEU 分数&#xff1a;翻译质量的标尺2.1 定义与原理2.2 计算方法2.3 应用与意义 三、其他评估指标&#xff1a;综合考量下的多元…...

《优化接口设计的思路》系列:第2篇—小程序性能优化

优化Uniapp应用程序的性能可以从以下几个方面进行优化&#xff1a; 1.减少页面加载时间&#xff1a;避免页面过多和过大的组件&#xff0c;减少不必要的资源加载。可以使用懒加载的方式&#xff0c;根据用户的实际需求来加载页面和组件。 2.节流和防抖&#xff1a;对于频繁触发…...

prototype 和 __proto__的区别

prototype 和 __proto__ 在 JavaScript 中都与对象的原型链有关&#xff0c;但它们各自有不同的用途和含义。 prototype prototype 是函数对象的一个属性&#xff0c;它指向一个对象&#xff0c;这个对象包含了可以由特定类型的所有实例共享的属性和方法。当我们创建一个新的…...

网络中未授权访问漏洞(Rsync,PhpInfo)

Rsync未授权访问漏洞 Rsync未授权访问漏洞是指Rsync服务配置不当或存在漏洞&#xff0c;导致攻击者可以未经授权访问和操作Rsync服务。Rsync是一个用于文件同步和传输的开源工具&#xff0c;通常在Unix/Linux系统上使用。当Rsync服务未经正确配置时&#xff0c;攻击者可以利用…...

DataWhaleAI分子预测夏令营 学习笔记

AI分子预测夏令营学习笔记 一、直播概览 主持人介绍 姓名&#xff1a;徐翼萌角色&#xff1a;DataWhale助教活动目的&#xff1a;分享机器学习赛事经验&#xff0c;提升参赛者在分子预测领域的能力 嘉宾介绍 姓名&#xff1a;余老师背景&#xff1a;Data成员&#xff0c;腾…...

lnmp php7 安装ssh2扩展

安装ssh2扩展前必须安装libssh2包 下载地址: wget http://www.libssh2.org/download/libssh2-1.11.0.tar.gzwget http://pecl.php.net/get/ssh2-1.4.tgz &#xff08;这里要换成最新的版本&#xff09; 先安装 libssh2 再安装 SSH2: tar -zxvf libssh2-1.11.0.tar.gzcd libss…...

数据库概念题总结

1、 2、简述数据库设计过程中&#xff0c;每个设计阶段的任务 需求分析阶段&#xff1a;从现实业务中获取数据表单&#xff0c;报表等分析系统的数据特征&#xff0c;数据类型&#xff0c;数据约束描述系统的数据关系&#xff0c;数据处理要求建立系统的数据字典数据库设计…...

提升用户体验之requestAnimationFrame实现前端动画

1)requestAnimationFrame是什么? 1.MDN官方解释 2.解析这段话&#xff1a; 1、那么浏览器重绘是指什么呢&#xff1f; ——大多数电脑的显示器刷新频率是60Hz&#xff0c;1000ms/6016.66666667ms的时间刷新一次 2、重绘之前调用指定的回调函数更新动画&#xff1f; ——requ…...

Mysql慢日志、慢SQL

慢查询日志 查看执行慢的SQL语句&#xff0c;需要先开启慢查询日志。 MySQL 的慢查询日志&#xff0c;记录在 MySQL 中响应时间超过阀值的语句&#xff08;具体指运行时间超过 long_query_time 值的SQL。long_query_time 的默认值为10&#xff0c;意思是运行10秒以上(不含10秒…...

卫星网络——Walker星座简单介绍

一、星座构型介绍 近年来&#xff0c;随着卫星应用领的不断拓展&#xff0c;许多任务已经无法单纯依靠单颗卫星来完成。与单个卫星相比&#xff0c;卫星星座的覆盖范围显著增加&#xff0c;合理的星座构型可以使其达到全球连续覆盖或全球多重连续覆盖&#xff0c;这样的特性使得…...

C++ Lambda表达式第一篇, 闭合(Closuretype)

C Lambda表达式第一篇&#xff0c; 闭合Closuretype ClosureType::operator()(params)auto 模板参数类型显式模板参数类型其他 ClosureType::operator ret(*)(params)() lambda 表达式是唯一的未命名&#xff0c;非联合&#xff0c;非聚合类类型&#xff08;称为闭包类型&#…...

移动校园(3):处理全校课程数据excel文档,实现空闲教室查询与课程表查询

首先打开教学平台 然后导出为excel文档 import mathimport pandas as pd import pymssql serverName 127.0.0.1 userName sa passWord 123456 databaseuniSchool conn pymssql.connect(serverserverName,useruserName,passwordpassWord,databasedatabase) cursor conn.cur…...

【MySQL】1.初识MySQL

初识MySQL 一.MySQL 安装1.卸载已有的 MySQL2.获取官方 yum 源3.安装 MySQL4.登录 MySQL5.配置 my.cnf 二.MySQL 数据库基础1.MySQL 是什么&#xff1f;2.服务器&#xff0c;数据库和表3.mysqld 的层状结构4.SQL 语句分类 一.MySQL 安装 1.卸载已有的 MySQL //查询是否有相关…...

查看电脑显卡(NVIDIA)应该匹配什么版本的CUDA Toolkit

被串行计算逼到要吐时&#xff0c;决定重拾CUDa了&#xff0c;想想那光速般的处理感觉&#xff08;夸张了&#xff09;不要太爽&#xff0c;记下我的闯关记录。正好我的电脑配了NVIDIA独显&#xff0c;GTX1650&#xff0c;有菜可以炒呀&#xff0c;没有英伟达的要绕道了。回到正…...

优化:遍历List循环查找数据库导致接口过慢问题

前提&#xff1a; 我们在写查询的时候&#xff0c;有时候会遇到多表联查&#xff0c;一遇到多表联查大家就会直接写sql语句&#xff0c;不会使用较为方便的LambdaQueryWrapper去查询了。作为一个2024新进入码农世界的小白&#xff0c;我喜欢使用LambdaQueryWrapper&#xff0c;…...

NoSQL 之 Redis 配置与常用命令

一、关系型数据库与非关系型数据库 1、数据库概述 &#xff08;1&#xff09;关系型数据库 关系型数据库是一个结构化的数据库&#xff0c;创建在关系模型&#xff08;二维表格模型&#xff09;基础上&#xff0c;一般面向于记 录。 SQL 语句&#xff08;标准数据查询语言&am…...

用SpringBoot打造坚固防线:轻松实现XSS攻击防御

在这篇博客中&#xff0c;我们将深入探讨如何使用SpringBoot有效防御XSS攻击。通过结合注解和过滤器的方式&#xff0c;我们可以为应用程序构建一个强大的安全屏障&#xff0c;确保用户数据不被恶意脚本所侵害。 目录 什么是XSS攻击&#xff1f;SpringBoot中的XSS防御策略使用…...

基于服务器使用 apt 安装、配置 Nginx

&#x1f9fe; 一、查看可安装的 Nginx 版本 首先&#xff0c;你可以运行以下命令查看可用版本&#xff1a; apt-cache madison nginx-core输出示例&#xff1a; nginx-core | 1.18.0-6ubuntu14.6 | http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages ng…...

MySQL 8.0 OCP 英文题库解析(十三)

Oracle 为庆祝 MySQL 30 周年&#xff0c;截止到 2025.07.31 之前。所有人均可以免费考取原价245美元的MySQL OCP 认证。 从今天开始&#xff0c;将英文题库免费公布出来&#xff0c;并进行解析&#xff0c;帮助大家在一个月之内轻松通过OCP认证。 本期公布试题111~120 试题1…...

Chrome 浏览器前端与客户端双向通信实战

Chrome 前端&#xff08;即页面 JS / Web UI&#xff09;与客户端&#xff08;C 后端&#xff09;的交互机制&#xff0c;是 Chromium 架构中非常核心的一环。下面我将按常见场景&#xff0c;从通道、流程、技术栈几个角度做一套完整的分析&#xff0c;特别适合你这种在分析和改…...

零知开源——STM32F103RBT6驱动 ICM20948 九轴传感器及 vofa + 上位机可视化教程

STM32F1 本教程使用零知标准板&#xff08;STM32F103RBT6&#xff09;通过I2C驱动ICM20948九轴传感器&#xff0c;实现姿态解算&#xff0c;并通过串口将数据实时发送至VOFA上位机进行3D可视化。代码基于开源库修改优化&#xff0c;适合嵌入式及物联网开发者。在基础驱动上新增…...

Java求职者面试指南:Spring、Spring Boot、Spring MVC与MyBatis技术解析

Java求职者面试指南&#xff1a;Spring、Spring Boot、Spring MVC与MyBatis技术解析 一、第一轮基础概念问题 1. Spring框架的核心容器是什么&#xff1f;它的作用是什么&#xff1f; Spring框架的核心容器是IoC&#xff08;控制反转&#xff09;容器。它的主要作用是管理对…...

C++实现分布式网络通信框架RPC(2)——rpc发布端

有了上篇文章的项目的基本知识的了解&#xff0c;现在我们就开始构建项目。 目录 一、构建工程目录 二、本地服务发布成RPC服务 2.1理解RPC发布 2.2实现 三、Mprpc框架的基础类设计 3.1框架的初始化类 MprpcApplication 代码实现 3.2读取配置文件类 MprpcConfig 代码实现…...

macOS 终端智能代理检测

&#x1f9e0; 终端智能代理检测&#xff1a;自动判断是否需要设置代理访问 GitHub 在开发中&#xff0c;使用 GitHub 是非常常见的需求。但有时候我们会发现某些命令失败、插件无法更新&#xff0c;例如&#xff1a; fatal: unable to access https://github.com/ohmyzsh/oh…...

前端调试HTTP状态码

1xx&#xff08;信息类状态码&#xff09; 这类状态码表示临时响应&#xff0c;需要客户端继续处理请求。 100 Continue 服务器已收到请求的初始部分&#xff0c;客户端应继续发送剩余部分。 2xx&#xff08;成功类状态码&#xff09; 表示请求已成功被服务器接收、理解并处…...

Java中栈的多种实现类详解

Java中栈的多种实现类详解&#xff1a;Stack、LinkedList与ArrayDeque全方位对比 前言一、Stack类——Java最早的栈实现1.1 Stack类简介1.2 常用方法1.3 优缺点分析 二、LinkedList类——灵活的双端链表2.1 LinkedList类简介2.2 常用方法2.3 优缺点分析 三、ArrayDeque类——高…...

AWS vs 阿里云:功能、服务与性能对比指南

在云计算领域&#xff0c;Amazon Web Services (AWS) 和阿里云 (Alibaba Cloud) 是全球领先的提供商&#xff0c;各自在功能范围、服务生态系统、性能表现和适用场景上具有独特优势。基于提供的引用[1]-[5]&#xff0c;我将从功能、服务和性能三个方面进行结构化对比分析&#…...