深入刨析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. */ 

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/web/40856.shtml
繁體地址,請注明出處:http://hk.pswp.cn/web/40856.shtml
英文地址,請注明出處:http://en.pswp.cn/web/40856.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Interpretability 與 Explainability 機器學習

「AI秘籍」系列課程: 人工智能應用數學基礎人工智能Python基礎人工智能基礎核心知識人工智能BI核心知識人工智能CV核心知識 Interpretability 模型和 Explainability 模型之間的區別以及為什么它可能不那么重要 當你第一次深入可解釋機器學習領域時,你會…

Zabbix配置文件中Server和ServerActive參數講解

目錄 參數總結 實例: Zabbix Server 配置 (zabbix_server.conf) Zabbix Agent 配置 (zabbix_agentd.conf) 配置文件解析 實際應用 Zabbix Server 配置文件 (zabbix_server.conf) 對代理端的影響 1. Server 參數 2. ServerActive 參數 Zabbix Agent 配置文…

ubuntu 22 安裝 lua 環境 編譯lua cjson 模塊

在 windows 下使用 cygwin 編譯 lua 和 cjson 簡直就是災難,最后還是到 ubuntu 下完成了。 1、下載lua源碼(我下載的 5.1 版本,后面還有一個小插曲), 直接解壓編譯,遇到一個 readline.h not found 的問題,需要安裝 re…

python使用langchain整合通義千文

首先pip安裝langchain和dashscope pip install langchain pip install langchain_community pip install dashscope --upgrade然后測試一下運行效果 from langchain_community.chat_models.tongyi import ChatTongyi from langchain.schema import HumanMessage #api_key可以…

如何使用C++中的內聯函數和編譯器優化

在C中,內聯函數(inline functions)是一種請求編譯器嘗試在調用點將函數體展開,而不是按照常規函數調用的方式(即產生調用指令、保存寄存器、棧幀操作等)來執行的特殊函數。內聯函數主要用于小的、頻繁調用的…

CentOS命令格式及常用命令

在CentOS中,系統目錄結構遵循了標準的Linux文件系統層次結構(Filesystem Hierarchy Standard,FHS)。下面是CentOS系統中一些重要的目錄及其用途的介紹: 1. /(根目錄):整個文件系統的…

207 課程表

題目 你這個學期必須選修 numCourses 門課程,記為 0 到 numCourses - 1 。 在選修某些課程之前需要一些先修課程。 先修課程按數組 prerequisites 給出,其中 prerequisites[i] [ai, bi] ,表示如果要學習課程 ai 則 必須 先學習課程 bi 。 …

ArcGIS Pro SDK (七)編輯 13 注解

ArcGIS Pro SDK (七)編輯 13 注解 文章目錄 ArcGIS Pro SDK (七)編輯 13 注解1 注釋構建工具2 以編程方式啟動編輯批注3 更新批注文本4 修改批注形狀5 修改批注文本圖形6 接地到網格 環境:Visual Studio 2022 .NET6 …

在 PostgreSQL 中,如何處理數據的版本控制?

文章目錄 一、使用時間戳字段進行版本控制二、使用版本號字段進行版本控制三、使用歷史表進行版本控制四、使用 RETURNING 子句獲取更新前后的版本五、使用數據庫觸發器進行版本控制 在 PostgreSQL 中,處理數據的版本控制可以通過多種方式實現,每種方式都…

ensorFlow是由Google開發的

TensorFlow是由Google開發的一個開源的深度學習框架。它提供了一種靈活且高效的方法來構建、訓練和部署各種機器學習模型。 TensorFlow的基本概念是計算圖(computational graph)。在TensorFlow中,用戶通過定義計算圖來描述模型的結構和計算流…

JVM(Java虛擬機)詳解(JVM 內存模型、堆、GC、直接內存、性能調優)

JVM(Java虛擬機) JVM 內存模型 結構圖 jdk1.8 結構圖(極簡) jdk1.8 結構圖(簡單) JVM(Java虛擬機): 是一個抽象的計算模型。如同一臺真實的機器,它有自己…

思維導圖插件--jsMind的使用

vue引入jsmind(右鍵菜單)_jsmind.menu.js-CSDN博客 第一版 vue-JsMind思維導圖實現(包含鼠標右鍵自定義菜單)_jsmind 右鍵菜單-CSDN博客 // 新增節點addNode() {console.log(this.get_selected_nodeid());this.get_selected_…

Vue的學習之數據與方法

前段期間&#xff0c;由于入職原因沒有學習&#xff0c;現在已經正式入職啦&#xff0c;接下來繼續加油學習。 一、數據與方法 文字備注已經在代碼中&#xff0c;方便自己學習和理解 <!DOCTYPE html> <html><head><meta charset"utf-8">&l…

如何使用HippoRAG增強LLM的記憶

大型語言模型&#xff08;LLM&#xff09;已經證明是一種非常寶貴的思考工具。經過大量文本、代碼和其他媒體數據集的訓練&#xff0c;它們能夠創作出接近人類水平的文章、翻譯語言、生成圖像&#xff0c;還能以信息豐富的方式回答人們提出的問題&#xff0c;甚至可以編寫不同類…

SQLite 附加數據庫

SQLite 附加數據庫 SQLite 是一種輕量級的數據庫管理系統,因其小巧、快速和易于使用而廣受歡迎。在 SQLite 中,可以將多個數據庫文件附加到單個數據庫連接中,從而允許用戶在不同的數據庫之間輕松切換和操作數據。本文將詳細介紹如何在 SQLite 中附加數據庫,并探討其使用場…

CANopen協議開發梳理總結筆記教程

0、提醒 CANOpen使用時&#xff0c;需要清楚什么是大端和小端&#xff0c;這對于CANOpen數據發送及解析時&#xff0c;有很大的幫助。且學習開發CANOpen時&#xff0c;需要具備一定的CAN基礎。 1、CANOpen協議介紹 ①、什么是CANOpen協議 CANOpen協議是一種架構在控制局域網絡…

基于CLIP特征的多模態大模型中的視覺短板問題

【論文極速讀】 基于CLIP特征的多模態大模型中的視覺短板問題 FesianXu 20240706 at Tencent WeChat search team 前言 今天讀到篇CVPR 24’的論文 [1]&#xff0c;討論了常見的多模態大模型&#xff08;大多都基于CLIP語義特征&#xff0c;以下簡稱為MLLM&#xff09;中的視覺…

若依 / ruoyi-ui:執行yarn dev 報錯 esnext.set.difference.v2.js in ./src/utils/index.js

一、報錯信息 These dependencies were not found: * core-js/modules/esnext.set.difference.v2.js in ./src/utils/index.js * core-js/modules/esnext.set.intersection.v2.js in ./src/utils/index.js * core-js/modules/esnext.set.is-disjoint-from.v2.js in ./src/utils…

Python處理表格數據常用的 N+個操作

Python作為一種強大且易用的編程語言&#xff0c;其在數據處理方面表現尤為出色。特別是當我們面對大量的表格數據時&#xff0c;Python的各類庫和工具可以極大地提高我們的工作效率。以下&#xff0c;我將詳細介紹Python處理表格數據常用的操作。 首先&#xff0c;我們需要安…

2024.7.5總結

今晚的總結是在圖書館前的梯子上寫的&#xff0c;我多次輾轉&#xff0c;可能是我最后一次看看這個學校了&#xff0c;明天就要踏上回家的旅途了。還有半個月入職&#xff0c;干脆回家看看&#xff0c;畢竟&#xff0c;工作以后機會不多了。 下午的時候&#xff0c;用順豐寄了…