Redis Time Series介绍和命令大全

Redis Time Series介绍和命令大全

  • Redis Time Series
    • 1 时序序列是什么
    • 2 Redis Time Series的特性
    • 3 內存模型
    • 4 命令详解
      • 命名链接表
      • 命名详解表
        • `TS.CREATE`
        • `TS.ADD`
        • `TS.ALTER`
        • `TS.CREATERULE`
        • `TS.DECRBY`
        • `TS.DEL`
        • `TS.DELETERULE`
        • `TS.GET`
        • `TS.INCRBY`
        • `TS.INFO`
        • `TS.MADD`
        • `TS.MGET`
        • `TS.MRANGE`
        • `TS.MREVRANGE`
        • `TS.QUERYINDEX`
        • `TS.RANGE`
        • `TS.REVRANGE`
      • 命令CRUD分类
        • 删除
    • 5 各类客户端
    • 6 可视化

Redis Time Series

Redis 时间序列结构允许您存储和查询带时间戳的数据点。

1 时序序列是什么

时间序列数据是指按时间顺序排列的一系列数据点,通常由时间戳和对应的数值组成。
时间序列数据库 Time Series Database (TSDB)
我们可以把它理解成二维坐标,横轴是时间,纵轴是量测值。
很多监控系统都是由时序序列存储器存储数据的,如Graphite。
常见的时序序列数据有哪些的呢?其实在我们的日常生活中是非常常见的。

  • 温度、湿度
  • 网站访问量、接口耗时
  • 机器性能指标(如CPU使用率、内存占用)

网上有文章说是可以使用Hash或者zset实现时序特性,我觉得不行。
Hash结构不利于查询,只能全量GET,这不就是典型的大KEY吗。
zset的member不能重复,时序数据在现实中必然会重复,存储模型不合适。

2 Redis Time Series的特性

  • 高容量插入,低延迟读取
  • 按开始时间和结束时间查询
  • 任何时间段的聚合查询(最小、最大、平均、总和、范围、计数、第一个、最后一个等)
  • 可配置的最大保留期
  • 为自动更新聚合时间序列降低采样和压缩

3 內存模型

时间序列是内存块的链表。每个区块都有一个预定义大小的样本。每个样本是一个128位元组:64位用于时间戳,64位用于值。

4 命令详解

时序序列的命令还是比较麻烦的,不知道为啥redis要推出这个模块,用其他的产品就可以了啊。

命名链接表

indexcommandurl
0TS.ADDhttps://redis.io/docs/latest/commands/ts.add/
1TS.ALTERhttps://redis.io/docs/latest/commands/ts.alter/
2TS.CREATEhttps://redis.io/docs/latest/commands/ts.create/
3TS.CREATERULEhttps://redis.io/docs/latest/commands/ts.createrule/
4TS.DECRBYhttps://redis.io/docs/latest/commands/ts.decrby/
5TS.DELhttps://redis.io/docs/latest/commands/ts.del/
6TS.DELETERULEhttps://redis.io/docs/latest/commands/ts.deleterule/
7TS.GEThttps://redis.io/docs/latest/commands/ts.get/
8TS.INCRBYhttps://redis.io/docs/latest/commands/ts.incrby/
9TS.INFOhttps://redis.io/docs/latest/commands/ts.info/
10TS.MADDhttps://redis.io/docs/latest/commands/ts.madd/
11TS.MGEThttps://redis.io/docs/latest/commands/ts.mget/
12TS.MRANGEhttps://redis.io/docs/latest/commands/ts.mrange/
13TS.MREVRANGEhttps://redis.io/docs/latest/commands/ts.mrevrange/
14TS.QUERYINDEXhttps://redis.io/docs/latest/commands/ts.queryindex/
15TS.RANGEhttps://redis.io/docs/latest/commands/ts.range/
16TS.REVRANGEhttps://redis.io/docs/latest/commands/ts.revrange/

命名详解表

TS.CREATE
commandTS.CREATE
syntaxTS.CREATE key
[RETENTION retentionPeriod]
[ENCODING <COMPRESSED
description

Create a new time series

time complexityO(1)
available inRedis Stack / TimeSeries 1.0.0
urlhttps://redis.io/docs/latest/commands/ts.create/
  • RETENTION retentionPeriod: 数据保存的过期时间,单位毫秒。也就是序列最大时间是T时,序列中的时间最小是T-retentionPeriod,小于这个时间点的数据被移除。该值设置成0则表示没有过期时间
  • ENCODING:specifies the series samples encoding format. 默认是COMPRESSED,UNCOMPRESSED占用内存太大
    • COMPRESSED, applies compression to the series samples.
    • UNCOMPRESSED, keeps the raw samples in memory.
  • CHUNK_SIZE size:initial allocation size, in bytes,
  • DUPLICATE_POLICY policy:加入到序列中有相同时间戳时如何处理,default is BLOCK
    • BLOCK: ignore any newly reported value and reply with an error
    • FIRST: ignore any newly reported value
    • LAST: override with the newly reported value
    • MIN: only override if the value is lower than the existing value
    • MAX: only override if the value is higher than the existing value
    • SUM: If a previous sample exists, add the new sample to it so that the updated value is equal to (previous + new).
      If no previous sample exists, set the updated value equal to the new value.
  • IGNORE ignoreMaxTimediff ignoreMaxValDiff:设置忽略样本值,DUPLICATE_POLICY处理的是相同时间戳的样本,
    IGNORE处理的则是临近的相似数据。如果timestamp (timestamp - max_timestamp) <ignoreMaxTimediff
    ,且abs(值newAdd - 值lastAdd) < ignoreMaxValDiff
    那么这个值不会被加入到序列中。default both set to 0. ignoreMaxTimediff单位ms,当然还有其他的条件。所有条件如下,所有条件都满足才不会加入到序列中
    • The time series is not a compaction;
    • The time series’ DUPLICATE_POLICY IS LAST;
    • The sample is added in-order (timestamp ≥ max_timestamp);
    • The difference of the current timestamp from the previous timestamp (timestamp - max_timestamp) is less - than or
      equal to IGNORE_MAX_TIME_DIFF;
    • The absolute value difference of the current value from the value at the previous maximum timestamp (abs(value -
      value_at_max_timestamp) is less than or equal to IGNORE_MAX_VAL_DIFF.
  1. 看这个例子, ignoreMaxTimediff=10000 ignoreMaxValDiff=5, ts.add加了三个样本,但是序列只有两个,最后一个样本被忽略了
# 看这个例子
127.0.0.1:6379> ts.create temp ENCODING UNCOMPRESSED DUPLICATE_POLICY LAST IGNORE 10000 5 LABELS tom 1 lixi 2
OK
127.0.0.1:6379> ts.add temp * 1110
(integer) 1729561167099
127.0.0.1:6379> ts.add temp * 1111
(integer) 1729561913855
127.0.0.1:6379> ts.add temp * 1110
(integer) 1729561913855
127.0.0.1:6379> 
127.0.0.1:6379> ts.range temp - +
1) 1) (integer) 17295611670992) 1110
2) 1) (integer) 17295619138552) 1111
127.0.0.1:6379> 
  • LABELS: 标签是key的元数据,以键值对方式存储
TS.ADD
commandTS.ADD
syntaxTS.ADD key timestamp value
[RETENTION retentionPeriod]
[ENCODING <COMPRESSED
description

Append a sample to a time series

time complexityO(M) when M is the amount of compaction rules or O(1) with no compaction
available inRedis Stack / TimeSeries 1.0.0
urlhttps://redis.io/docs/latest/commands/ts.add/
TS.ALTER
commandTS.ALTER
syntaxTS.ALTER key
[RETENTION retentionPeriod]
[CHUNK_SIZE size]
[DUPLICATE_POLICY policy]
[IGNORE ignoreMaxTimediff ignoreMaxValDiff]
[LABELS [label value …]]
description

Update the retention, chunk size, duplicate policy, and labels of an existing time series

time complexityO(N) where N is the number of labels requested to update
available inRedis Stack / TimeSeries 1.0.0
urlhttps://redis.io/docs/latest/commands/ts.alter/
127.0.0.1:6379> ts.alter temperature labels nmae lixi 
OK
TS.CREATERULE
commandTS.CREATERULE
syntaxTS.CREATERULE sourceKey destKey
AGGREGATION aggregator bucketDuration
[alignTimestamp]
description

Create a compaction rule

time complexityO(1)
available inRedis Stack / TimeSeries 1.0.0
urlhttps://redis.io/docs/latest/commands/ts.createrule/
TS.DECRBY
commandTS.DECRBY
syntaxTS.DECRBY key subtrahend
[TIMESTAMP timestamp]
[RETENTION retentionPeriod]
[ENCODING <COMPRESSED
description

Decrease the value of the sample with the maximum existing timestamp, or create a new sample with a value equal to the value of the sample with the maximum existing timestamp with a given decrement

time complexityO(M) when M is the amount of compaction rules or O(1) with no compaction
available inRedis Stack / TimeSeries 1.0.0
urlhttps://redis.io/docs/latest/commands/ts.decrby/
TS.DEL
commandTS.DEL
syntaxTS.DEL key fromTimestamp toTimestamp
description

Delete all samples between two timestamps for a given time series

time complexityO(N) where N is the number of data points that will be removed
available inRedis Stack / TimeSeries 1.6.0
urlhttps://redis.io/docs/latest/commands/ts.del/
127.0.0.1:6379> ts.del temperature - +
(integer) 6
TS.DELETERULE
commandTS.DELETERULE
syntaxTS.DELETERULE sourceKey destKey
description

Delete a compaction rule

time complexityO(1)
available inRedis Stack / TimeSeries 1.0.0
urlhttps://redis.io/docs/latest/commands/ts.deleterule/
TS.GET
commandTS.GET
syntaxTS.GET key
[LATEST]
description

Get the sample with the highest timestamp from a given time series

time complexityO(1)
available inRedis Stack / TimeSeries 1.0.0
urlhttps://redis.io/docs/latest/commands/ts.get/
127.0.0.1:6379> TS.GET temperature
1) (integer) 1729563143127
2) 40
127.0.0.1:6379> 
TS.INCRBY
commandTS.INCRBY
syntaxTS.INCRBY key addend
[TIMESTAMP timestamp]
[RETENTION retentionPeriod]
[ENCODING <COMPRESSED
description

Increase the value of the sample with the maximum existing timestamp, or create a new sample with a value equal to the value of the sample with the maximum existing timestamp with a given increment

time complexityO(M) when M is the amount of compaction rules or O(1) with no compaction
available inRedis Stack / TimeSeries 1.0.0
urlhttps://redis.io/docs/latest/commands/ts.incrby/
TS.INFO
commandTS.INFO
syntaxTS.INFO key
[DEBUG]
description

Return information and statistics for a time series.

time complexityO(1)
available inRedis Stack / TimeSeries 1.0.0
urlhttps://redis.io/docs/latest/commands/ts.info/
127.0.0.1:6379> TS.INFO temperature1) totalSamples2) (integer) 33) memoryUsage4) (integer) 42105) firstTimestamp6) (integer) 17295631379037) lastTimestamp8) (integer) 17295631431279) retentionTime
10) (integer) 0
11) chunkCount
12) (integer) 1
13) chunkSize
14) (integer) 4096
15) chunkType
16) compressed
17) duplicatePolicy
18) (nil)
19) labels
20) 1) 1) "nmae"2) "lixi"
21) sourceKey
22) (nil)
23) rules
24) (empty array)
25) ignoreMaxTimeDiff
26) (integer) 0
27) ignoreMaxValDiff
28) "0"
127.0.0.1:6379> 
TS.MADD
commandTS.MADD
syntaxTS.MADD {key timestamp value}…
description

Append new samples to one or more time series

time complexityO(N*M) when N is the amount of series updated and M is the amount of compaction rules or O(N) with no compaction
available inRedis Stack / TimeSeries 1.0.0
urlhttps://redis.io/docs/latest/commands/ts.madd/
TS.MGET
commandTS.MGET
syntaxTS.MGET [LATEST] [WITHLABELS | <SELECTED_LABELS label…>] FILTER filterExpr…
description

Get the sample with the highest timestamp from each time series matching a specific filter

time complexityO(n) where n is the number of time-series that match the filters
available inRedis Stack / TimeSeries 1.0.0
urlhttps://redis.io/docs/latest/commands/ts.mget/
127.0.0.1:6379> ts.mget filter lixi=2
1) 1) "temp"2) (empty array)3) 1) (integer) 17295619138552) 1111
127.0.0.1:6379> 
127.0.0.1:6379> 
127.0.0.1:6379> 
127.0.0.1:6379> ts.mget withlabels filter lixi=2
1) 1) "temp"2) 1) 1) "tom"2) "1"2) 1) "lixi"2) "2"3) 1) (integer) 17295619138552) 1111
127.0.0.1:6379> 
TS.MRANGE
commandTS.MRANGE
syntaxTS.MRANGE fromTimestamp toTimestamp
[LATEST]
[FILTER_BY_TS ts…]
[FILTER_BY_VALUE min max]
[WITHLABELS
description

Query a range across multiple time series by filters in the forward direction

time complexityO(n/m+k) where n = Number of data points, m = Chunk size (data points per chunk), k = Number of data points that are in the requested ranges
available inRedis Stack / TimeSeries 1.0.0
urlhttps://redis.io/docs/latest/commands/ts.mrange/
127.0.0.1:6379> ts.mrange - + filter nmae=lixi
1) 1) "temperature"2) (empty array)3) 1) 1) (integer) 17295631379032) 382) 1) (integer) 17295631404972) 393) 1) (integer) 17295631431272) 40
127.0.0.1:6379> 
127.0.0.1:6379> ts.mrange - + filter_by_value 39 40 filter nmae=lixi
1) 1) "temperature"2) (empty array)3) 1) 1) (integer) 17295631404972) 392) 1) (integer) 17295631431272) 40
127.0.0.1:6379> 
127.0.0.1:6379> ts.mrange - + filter_by_ts  1729563140497 1729563142497 filter_by_value 39 40 filter nmae=lixi
1) 1) "temperature"2) (empty array)3) 1) 1) (integer) 17295631404972) 39
TS.MREVRANGE
commandTS.MREVRANGE
syntaxTS.MREVRANGE fromTimestamp toTimestamp
[LATEST]
[FILTER_BY_TS ts…]
[FILTER_BY_VALUE min max]
[WITHLABELS
description

Query a range across multiple time series by filters in the reverse direction

time complexityO(n/m+k) where n = Number of data points, m = Chunk size (data points per chunk), k = Number of data points that are in the requested ranges
available inRedis Stack / TimeSeries 1.4.0
urlhttps://redis.io/docs/latest/commands/ts.mrevrange/
127.0.0.1:6379> 
127.0.0.1:6379> 
127.0.0.1:6379> ts.mrevrange - + filter nmae=lixi
1) 1) "temperature"2) (empty array)3) 1) 1) (integer) 17295631431272) 402) 1) (integer) 17295631404972) 393) 1) (integer) 17295631379032) 38
127.0.0.1:6379> 
127.0.0.1:6379> 
TS.QUERYINDEX
commandTS.QUERYINDEX
syntaxTS.QUERYINDEX filterExpr…
description

Get all time series keys matching a filter list

time complexityO(n) where n is the number of time-series that match the filters
available inRedis Stack / TimeSeries 1.0.0
urlhttps://redis.io/docs/latest/commands/ts.queryindex/
127.0.0.1:6379> ts.queryindex lixi=2
1) "temp"
TS.RANGE
commandTS.RANGE
syntaxTS.RANGE key fromTimestamp toTimestamp
[LATEST]
[FILTER_BY_TS ts…]
[FILTER_BY_VALUE min max]
[COUNT count]
[[ALIGN align] AGGREGATION aggregator bucketDuration [BUCKETTIMESTAMP bt] [EMPTY]]
description

Query a range in forward direction

time complexityO(n/m+k) where n = Number of data points, m = Chunk size (data points per chunk), k = Number of data points that are in the requested range
available inRedis Stack / TimeSeries 1.0.0
urlhttps://redis.io/docs/latest/commands/ts.range/
127.0.0.1:6379> ts.range temperature - +
1) 1) (integer) 17295631379032) 38
2) 1) (integer) 17295631404972) 39
3) 1) (integer) 17295631431272) 40
127.0.0.1:6379> 
TS.REVRANGE
commandTS.REVRANGE
syntaxTS.REVRANGE key fromTimestamp toTimestamp
[LATEST]
[FILTER_BY_TS ts…]
[FILTER_BY_VALUE min max]
[COUNT count]
[[ALIGN align] AGGREGATION aggregator bucketDuration [BUCKETTIMESTAMP bt] [EMPTY]]
description

Query a range in reverse direction

time complexityO(n/m+k) where n = Number of data points, m = Chunk size (data points per chunk), k = Number of data points that are in the requested range
available inRedis Stack / TimeSeries 1.4.0
urlhttps://redis.io/docs/latest/commands/ts.revrange/
127.0.0.1:6379> 
127.0.0.1:6379> TS.REVRANGE temperature - + filter nmae=lixi
1) 1) (integer) 17295631431272) 40
2) 1) (integer) 17295631404972) 39
3) 1) (integer) 17295631379032) 38
127.0.0.1:6379> 

命令CRUD分类

TS.CREATE: 创建序列
TS.CREATERULE: 创建压缩规则

删除

TS.DEL:删除指定时序中两个时间戳之前的所有样本
TS.DELETERULE: 删除压缩规则

TS.ALTER: 更新现有时序的保留期、区块大小、重复策略和标签等
TS.ADD: 添加一个样本到时序中,不存在key也会新建,如果设为*表示根据服务器当前时间设置时间戳。
TS.MADD:在一个或多个时序中添加样本
TS.DECRBY: 减少时序中存在的最大时间戳的样本值;如果该时序不存在,则创建该时序并添加value到样本中;
时序存在但是没有样本,则把value添加为一个新的样本值 。
TS.INCRBY: 增加时序中存在的最大时间戳的样本值;如果该时序不存在,则创建该时序并添加value到样本中;
时序存在但是没有样本,则把value添加为一个新的样本值 。

TS.INFO:返回时序的信息(含统计信息)
TS.GET:从指定的时序中获取时间戳最高的样本数据。
TS.MGET:从满足筛选条件的时序中获取时间戳最大的样本
TS.QUERYINDEX:获取满足筛选条件的所有时序key,注意是查找key。
TS.RANGE: 正向查询范围, TS.RANGE key - +,-表示最小时间戳,+表示最大时间戳。
TS.MRANGE: 通过过滤器正向查询多个时序
TS.MREVRANGE: 通过过滤器反向查询多个时序,查询结果是按时间戳倒序的
TS.REVRANGE: 反向查询范围,查询结果是按时间戳倒序的

5 各类客户端

https://redis.io/docs/latest/develop/data-types/timeseries/clients/

LanguageClient
Python redis-py
JavaScript node-redis
Java Jedis
C#/.NET NRedisStack
Go redistimeseries-go
  • java客户端看 redis_into或者
package com.tom;import redis.clients.jedis.UnifiedJedis;
import redis.clients.jedis.timeseries.TSCreateParams;
import redis.clients.jedis.timeseries.TSElement;import java.util.List;/*** @author*/
public class TestRedisTS {private static final String KEY = "jerry";private static final String URL = "redis://localhost:6379";public static void main(String[] args) {UnifiedJedis jedis = new UnifiedJedis(URL);TSCreateParams tsCreateParams = TSCreateParams.createParams();tsCreateParams.label("lixi", "18").label("tom", KEY).retention(1000 * 10);boolean exists = jedis.exists(KEY);if (exists) {jedis.del(KEY);}String s = jedis.tsCreate(KEY, tsCreateParams);System.out.println(s);long l = jedis.tsAdd(KEY, 123);System.out.println(l);long l1 = jedis.tsAdd(KEY, l - 1000 * 3, 100);System.out.println(l1);List<TSElement> tsElements = jedis.tsRevRange(KEY, l1, l);System.out.println(tsElements);List<String> strings = jedis.tsQueryIndex("lixi=18");System.out.println(strings);jedis.close();}
}
OK
1729573329323
1729573326323
[(1729573329323:123.0), (1729573326323:100.0)]
[jerry]

6 可视化

Time Series with RedisInsight
在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/bicheng/57475.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

WORFBENCH:一个创新的评估基准,目的是全面测试大型语言模型在生成复杂工作流 方面的性能。

2024-10-10,由浙江大学和阿里巴巴集团联合创建的WORFBENCH&#xff0c;一个用于评估大型语言模型&#xff08;LLMs&#xff09;生成工作流能力的基准测试。它包含了一系列的测试和评估协议&#xff0c;用于量化和分析LLMs在处理复杂任务时分解问题和规划执行步骤的能力。WORFBE…

微信小程序文本收起展开

这里写自定义目录标题 微信小程序文本收起展开常见问题的梯形背景框 微信小程序文本收起展开 参考 https://juejin.cn/post/6963904955262435336 <!-- 常见问题解答 --><view classcontentBottom><view classBottomFirst><text id0 data-id0 class&quo…

安装buildkit,并使用buildkit构建containerd镜像

背景 因为K8s抛弃Docker了,所以就只装了个containerd,这样就需要一个单独的镜像构建工具了,就用了buildkit,这也是Docker公司扶持的,他们公司的人出来搞的开源工具,官网在 https://github.com/moby/buildkit 简介 服务端为buildkitd,负责和runc或containerd后端连接干活,目前…

魔音音乐 5.0.1 | 界面优美,可无损下载,可播放

魔音Morin 是一款免费下载付费音乐和免费播放音乐的软件。现在听歌都需要付费&#xff0c;不想付费听音乐就来魔音Morin&#xff0c;完全免费的音乐资源非常丰富&#xff0c;可同步四大音乐平台歌单&#xff0c;还有各类音乐榜单&#xff0c;自带音乐社、同步歌单以及搜索音乐功…

iTOP-RK3568开发板独立NPU通过算法加特应用到以下的场景

iTOP-3568开发板采用瑞芯微RK3568处理器&#xff0c;内部集成了四核64位Cortex-A55处理器。主频高达2.0Ghz&#xff0c;RK809动态调频。集成了双核心架构GPU&#xff0c;ARM G52 2EE、支持OpenGLES1.1/2.0/3.2、OpenCL2.0、Vulkan1.1、内嵌高性能2D加速硬件。 内置独立NPU,算力…

国内大语言模型哪家更好用?

大家好&#xff0c;我是袁庭新。 过去一年&#xff0c;AI大语言模型在爆发式增长&#xff0c;呈现百家争鸣之态。国内外相关厂商积极布局&#xff0c;并相继推出自家研发的智能化产品。 我在工作中已习惯借助AI来辅助完成些编码、创作、文生图等任务&#xff0c;甚至对它们产…

基于Springboot在线视频网站的设计与实现

基于Springboot视频网站的设计与实现 开发语言&#xff1a;Java 框架&#xff1a;springboot JDK版本&#xff1a;JDK1.8 服务器&#xff1a;tomcat7 数据库&#xff1a;mysql 5.7 数据库工具&#xff1a;Navicat11 开发软件&#xff1a;idea 源码获取&#xff1a;https://do…

Android 开发 TabLayout 自定义指示器长度

前言 原生 TabLayout 的指示器长度是充满整个屏幕的&#xff0c;但在实际开发中 UI 会设计成 指示器的长度等于或者小于标题字体长度&#xff0c;如图 如果设置成跟字体长度一样即使用 API: mTabLayout.setTabIndicatorFullWidth(false);或者在 xml 布局文件中的TabLayout标签…

vscode配色主题推荐:Andromeda !

vscode配色主题推荐:Andromeda ! 图标库 vscode-icons ! Andromeda:Dark theme with a taste of the universe&#xff1b; 仙女座&#xff1a;一套宇宙深空体验的哑暗色主题; 高对比度,色彩饱和; Easy Installation Open the extensions sidebar on Visual Studio CodeSearc…

判断自己的mac是macOS x64 还是macOS ARM64

在终端输入 uname -a 这样的是x64 这样的是ARM64

Skydel 24.9版本震撼发布,升级五大关键功能

在信号传播与仿真领域&#xff0c;Skydel软件一直是行业内的佼佼者。我们与您分享升级快讯&#xff0c;Skydel软件24.9.0版本已正式发布&#xff0c;此次更新不仅带来了五大全新功能&#xff0c;还在性能优化、用户体验以及远程API方面进行了全面升级&#xff0c;为用户带来更高…

面试题:如何能够保证T2在T1执行完后执行,T3在T2执行完后执行?——CountDownLatch原理

CountDownLatch的使用方式 CountDownLatch用于某个线程等待其他线程执行完任务再执行&#xff0c;与thread.join()功能类似。常见的应用场景是开启多个线程同时执行某个任务&#xff0c;等到所有任务执行完再执行特定操作&#xff0c;如汇总统计结果。 面试题&#xff1a;如何…

最新Java零基础知识(持续更新中......)

1. 学习前的准备 一个好的学习方法&#xff08;如何更高效学习&#xff09;&#xff1a; 成为一名合格的程序员&#xff0c;需要具备两个关键能力&#xff1a; 指法速度&#xff1a;高效的代码输入速度。编程思想&#xff1a;能够用编程的方式解决现实问题的能力。 指法速度&am…

SpringBoot中的Component和ComponentScan注解工作原理

Spring IoC 容器的工作是通过管理对象的生命周期和配置来保持业务逻辑清晰&#xff0c;但是 Spring 容器并不会自动知道要管理哪些 bean。所以我们来告诉 Spring 应该处理哪些 bean 以及如何处理&#xff0c;很简单这就是 Spring 的 Component 和 ComponentScan 注释的作用所在…

算法题总结(二十)——并查集

并查集理论基础 并查集常用来解决集合连通性问题&#xff0c;两个节点在不在一个集合&#xff0c;也可以将两个节点添加到一个集合中。 大白话就是当我们需要判断两个元素是否在同一个集合里的时候&#xff0c;我们就要想到用并查集。 并查集主要有两个功能&#xff1a; 将…

linux介绍与基本指令

前言 本次博客将会讲解linux的来源历史、linux操作系统的理解以及它的一些基本指令。 1.linux的介绍 linux的来源 linux的来源最初还是要说到unix操作系统的。 1968年&#xff0c;一些来自通用电器公司、贝尔实验室和麻省理工学院的研究人员开发了一个名叫Multics的特殊操作…

C语言 | Leetcode C语言题解之第502题IPO

题目&#xff1a; 题解&#xff1a; #define MIN(a, b) ((a) < (b) ? (a) : (b)) #define MAX_INT_NUMBER 0x7FFFFFFEtypedef struct {int capital;int profit; } ProNode;int CompareProfit(const ProNode *a, const ProNode *b) { /* 从大到小排序 */return b->pr…

根据发生异常的汇编指令以及函数调用堆栈,从内存的角度出发,估计出问题的可能原因,确定排查方向,快速定位C++软件问题

目录 1、前言 2、初步分析dump文件 3、加载更多模块的pdb文件&#xff0c;可能能看到更多行的函数调用堆栈 4、从内存的角度去看&#xff0c;估计是访问了野指针导致的&#xff0c;沿着这个怀疑的方向快速地定位了问题 5、最后 C软件异常排查从入门到精通系列教程&#xf…

力扣OJ算法题:合并两个有序链表

—————————————————————————————————————————— 正文开始 OJ算法题&#xff1a;合并两个有序链表 思路 创建一个新的空链表&#xff08;可以用malloc优化&#xff09;和两个指针L1、L2分别指向两个链表&#xff0c;遍历两个链表&am…

Chromium 中chrome.contextMenus扩展接口实现分析c++

一、chrome.contextMenus 使用 chrome.contextMenus API 向 Google Chrome 的上下文菜单中添加项。您可以选择从右键菜单中添加的对象类型&#xff0c;例如图片、超链接和页面。 权限 contextMenus 您必须在扩展程序的清单中声明 "contextMenus" 权限&#xff0c…