当前位置: 首页 > 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防御策略使用…...

wordpress后台更新后 前端没变化的解决方法

使用siteground主机的wordpress网站&#xff0c;会出现更新了网站内容和修改了php模板文件、js文件、css文件、图片文件后&#xff0c;网站没有变化的情况。 不熟悉siteground主机的新手&#xff0c;遇到这个问题&#xff0c;就很抓狂&#xff0c;明明是哪都没操作错误&#x…...

后进先出(LIFO)详解

LIFO 是 Last In, First Out 的缩写&#xff0c;中文译为后进先出。这是一种数据结构的工作原则&#xff0c;类似于一摞盘子或一叠书本&#xff1a; 最后放进去的元素最先出来 -想象往筒状容器里放盘子&#xff1a; &#xff08;1&#xff09;你放进的最后一个盘子&#xff08…...

《Qt C++ 与 OpenCV:解锁视频播放程序设计的奥秘》

引言:探索视频播放程序设计之旅 在当今数字化时代,多媒体应用已渗透到我们生活的方方面面,从日常的视频娱乐到专业的视频监控、视频会议系统,视频播放程序作为多媒体应用的核心组成部分,扮演着至关重要的角色。无论是在个人电脑、移动设备还是智能电视等平台上,用户都期望…...

04-初识css

一、css样式引入 1.1.内部样式 <div style"width: 100px;"></div>1.2.外部样式 1.2.1.外部样式1 <style>.aa {width: 100px;} </style> <div class"aa"></div>1.2.2.外部样式2 <!-- rel内表面引入的是style样…...

用docker来安装部署freeswitch记录

今天刚才测试一个callcenter的项目&#xff0c;所以尝试安装freeswitch 1、使用轩辕镜像 - 中国开发者首选的专业 Docker 镜像加速服务平台 编辑下面/etc/docker/daemon.json文件为 {"registry-mirrors": ["https://docker.xuanyuan.me"] }同时可以进入轩…...

C++ Visual Studio 2017厂商给的源码没有.sln文件 易兆微芯片下载工具加开机动画下载。

1.先用Visual Studio 2017打开Yichip YC31xx loader.vcxproj&#xff0c;再用Visual Studio 2022打开。再保侟就有.sln文件了。 易兆微芯片下载工具加开机动画下载 ExtraDownloadFile1Info.\logo.bin|0|0|10D2000|0 MFC应用兼容CMD 在BOOL CYichipYC31xxloaderDlg::OnIni…...

python报错No module named ‘tensorflow.keras‘

是由于不同版本的tensorflow下的keras所在的路径不同&#xff0c;结合所安装的tensorflow的目录结构修改from语句即可。 原语句&#xff1a; from tensorflow.keras.layers import Conv1D, MaxPooling1D, LSTM, Dense 修改后&#xff1a; from tensorflow.python.keras.lay…...

回溯算法学习

一、电话号码的字母组合 import java.util.ArrayList; import java.util.List;import javax.management.loading.PrivateClassLoader;public class letterCombinations {private static final String[] KEYPAD {"", //0"", //1"abc", //2"…...

【Linux】Linux 系统默认的目录及作用说明

博主介绍&#xff1a;✌全网粉丝23W&#xff0c;CSDN博客专家、Java领域优质创作者&#xff0c;掘金/华为云/阿里云/InfoQ等平台优质作者、专注于Java技术领域✌ 技术范围&#xff1a;SpringBoot、SpringCloud、Vue、SSM、HTML、Nodejs、Python、MySQL、PostgreSQL、大数据、物…...

【JVM】Java虚拟机(二)——垃圾回收

目录 一、如何判断对象可以回收 &#xff08;一&#xff09;引用计数法 &#xff08;二&#xff09;可达性分析算法 二、垃圾回收算法 &#xff08;一&#xff09;标记清除 &#xff08;二&#xff09;标记整理 &#xff08;三&#xff09;复制 &#xff08;四&#xff…...