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

java语言里redis在项目中使用场景,每个场景的样例代码

Redis是一款高性能的NoSQL数据库,常被用于缓存、消息队列、计数器、分布式锁等场景。以下是50个Redis在项目中使用的场景以及对应的样例代码和详细说明:

##1、缓存:将查询结果缓存在Redis中,下次查询时直接从缓存中获取,减少数据库查询次数。

// 设置缓存
redisTemplate.opsForValue().set("key", "value", Duration.ofMinutes(10));
// 获取缓存
String value = redisTemplate.opsForValue().get("key");

##2、分布式锁:多个进程/线程同时访问一个资源时,使用Redis实现分布式锁,保证同一时刻只有一个进程/线程访问该资源。

// 加锁
Boolean locked = redisTemplate.opsForValue().setIfAbsent("lock_key", "lock_value", Duration.ofSeconds(30));
if (locked) {try {// 执行业务逻辑} finally {// 释放锁redisTemplate.delete("lock_key");}
}

##3、计数器:实现用户访问量、文章浏览量等计数功能。

// 计数器加1
redisTemplate.opsForValue().increment("counter_key");
// 获取计数器值
Long counter = redisTemplate.opsForValue().get("counter_key");
队列:实现任务异步处理、消息队列等功能。// 生产者向队列中添加消息
redisTemplate.opsForList().leftPush("queue_key", "message");
// 消费者从队列中获取消息
String message = redisTemplate.opsForList().rightPop("queue_key");
发布/订阅:实现实时消息推送、事件通知等功能。// 发布消息
redisTemplate.convertAndSend("channel", "message");
// 订阅消息
redisTemplate.execute(new RedisCallback<Void>() {@Overridepublic Void doInRedis(RedisConnection connection) throws DataAccessException {connection.subscribe((message, pattern) -> {// 处理接收到的消息}, "channel".getBytes());return null;}
});

##4、分布式缓存:多节点部署时,使用Redis实现分布式缓存,提高缓存命中率。

// 设置缓存
redisTemplate.opsForValue().set("key", "value", Duration.ofMinutes(10));
// 获取缓存
String value = redisTemplate.opsForValue().get("key");
排行榜:实现用户积分排行榜、文章点赞排行榜等功能。// 新增用户积分
redisTemplate.opsForZSet().add("ranking_key", "user_id", score);
// 获取用户排名
Long rank = redisTemplate.opsForZSet().reverseRank("ranking_key", "user_id");

##5、搜索引擎:使用Redis实现搜索引擎的缓存、索引等功能。

// 将搜索结果缓存到Redis中
redisTemplate.opsForValue().set("search_key", "search_result", Duration.ofMinutes(10));
// 从Redis中获取搜索结果
String searchResult = redisTemplate.opsForValue().get("search_key");
分布式事务:使用Redis实现分布式事务,保证多个操作的原子性。// 开启事务
redisTemplate.multi();
// 执行多个操作
redisTemplate.opsForValue().set("key1", "value1");
redisTemplate.opsForValue().set("key2", "value2");
// 提交事务
List<Object> results = redisTemplate.exec();

##6、地理位置:使用Redis实现地理位置相关功能,如附近的人、附近的商家等。

// 添加地理位置信息
redisTemplate.opsForGeo().add("location_key", new Point(116.405285, 39.904989), "user_id");
// 获取附近的人
GeoResults<RedisGeoCommands.GeoLocation<String>> results = redisTemplate.opsForGeo().radius("location_key", new Circle(new Point(116.405285, 39.904989), new Distance(1, Metrics.KILOMETERS)));

##7、聊天室:使用Redis实现聊天室功能,支持实时聊天、消息记录等。

// 加入聊天室
redisTemplate.opsForSet().add("chat_room_key", "user_id");
// 发送消息
redisTemplate.opsForList().leftPush("chat_message_key", "message");
// 获取聊天室成员列表
Set<String> members = redisTemplate.opsForSet().members("chat_room_key");
// 获取聊天记录
List<String> messages = redisTemplate.opsForList().range("chat_message_key", 0, -1);
数据缓存:使用Redis实现数据缓存,提高系统性能。// 设置缓存
redisTemplate.opsForValue().set("key", "value", Duration.ofMinutes(10));
// 获取缓存
String value = redisTemplate.opsForValue().get("key");

##8、验证码:使用Redis实现验证码功能,支持短信验证码、图形验证码等。

// 生成验证码
String code = generateCode();
// 将验证码缓存到Redis中
redisTemplate.opsForValue().set("code_key", code, Duration.ofMinutes(5));
// 发送验证码
sendCode(code);
// 验证验证码
String storedCode = redisTemplate.opsForValue().get("code_key");
if (code.equals(storedCode)) {// 验证通过
} else {// 验证失败
}
文件上传:使用Redis实现文件上传功能,支持分片上传、断点续传等。// 上传文件
byte[] fileData = getFileData();
redisTemplate.opsForValue().set("file_key", fileData);
// 下载文件
byte[] fileData = redisTemplate.opsForValue().get("file_key");

##9、限流:使用Redis实现限流功能,控制请求流量。

// 限制每秒最多处理10个请求
String key = "limit_key:" + System.currentTimeMillis() / 1000;
Long count = redisTemplate.opsForValue().increment(key, 1);
if (count == 1) {redisTemplate.expire(key, 1, TimeUnit.SECONDS);
} else if (count > 10) {throw new RuntimeException("too many requests");
}

##10、日志:使用Redis实现日志功能,支持日志记录、日志查询等。

// 记录日志
redisTemplate.opsForList().leftPush("log_key", "log_message");
// 查询日志
List<String> logs = redisTemplate.opsForList().range("log_key", 0, -1);

##11、分布式缓存锁:使用Redis实现分布式缓存锁,避免缓存雪崩。

// 加锁
Boolean locked = redisTemplate.opsForValue().setIfAbsent("lock_key", "lock_value", Duration.ofMinutes(10));
if (locked) {try {// 从缓存中获取数据String data = redisTemplate.opsForValue().get("data_key");if (data == null) {// 缓存中没有数据,从数据库中获取data = getDataFromDatabase();// 将数据缓存到Redis中redisTemplate.opsForValue().set("data_key", data, Duration.ofMinutes(10));}} finally {// 释放锁redisTemplate.delete("lock_key");}
}

##12、短链接:使用Redis实现短链接功能,将长链接转换为短链接。

// 生成短链接
String shortUrl = generateShortUrl();
// 将短链接与长链接映射关系缓存到Redis中
redisTemplate.opsForValue().set("url_mapping_key:" + shortUrl, "long_url", Duration.ofDays(30));
// 获取长链接
String longUrl = redisTemplate.opsForValue().get("url_mapping_key:" + shortUrl);

##13、会话管理:使用Redis实现会话管理功能,支持单点登录、会话过期等。

// 将会话信息缓存到Redis中
redisTemplate.opsForValue().set("session_key:" + sessionId, "user_id", Duration.ofMinutes(30));
// 验证会话是否有效
String userId = redisTemplate.opsForValue().get("session_key:" + sessionId);
if (userId == null) {// 会话无效
} else {// 会话有效
}

##14、数据统计:使用Redis实现数据统计功能,支持用户行为统计、业务数据统计等。

// 统计用户行为
redisTemplate.opsForValue().increment("behavior_key:" + userId + ":click", 1);
// 获取用户行为统计结果
Long clickCount = redisTemplate.opsForValue().get("behavior_key:" + userId + ":click");

##15、频率控制:使用Redis实现频率控制功能,控制用户请求频率。

// 限制每分钟最多处理10个请求
String key = "limit_key:" + System.currentTimeMillis() / 60000;
Long count = redisTemplate.opsForValue().increment(key, 1);
if (count == 1) {redisTemplate.expire(key, 1, TimeUnit.MINUTES);
} else if (count > 10) {throw new RuntimeException("too many requests");
}

##16、倒计时:使用Redis实现倒计时功能,支持秒杀活动、限时抢购等。

// 设置倒计时
redisTemplate.opsForValue().set("countdown_key", "countdown_value", Duration.ofSeconds(60));
// 获取倒计时剩余时间
Long remainingTime = redisTemplate.opsForValue().getOperations().getExpire("countdown_key");

##17、活动抽奖:使用Redis实现活动抽奖功能,支持随机抽奖、概率抽奖等。

// 添加奖品
redisTemplate.opsForList().rightPushAll("prize_key", "prize1", "prize2", "prize3");
// 抽奖
String prize = redisTemplate.opsForList().leftPop("prize_key");
分布式任务调度:使用Redis实现分布式任务调度,支持定时任务、
接下来再举例java语言里redis在项目中使用场景,每个场景的样例代码,列出二十个项目场景,详细说明

##18、分布式缓存更新:使用Redis实现分布式缓存更新,保证缓存数据的一致性。

// 更新数据
updateData();
// 将缓存标记为失效
redisTemplate.delete("cache_key");
// 在其他节点上查询缓存时发现已失效,从数据库中重新加载数据并更新缓存

##19、分布式事务消息:使用Redis实现分布式事务消息,支持跨服务的事务消息处理。

// 提交事务消息
redisTemplate.execute(new SessionCallback<Void>() {@Overridepublic Void execute(RedisOperations operations) throws DataAccessException {operations.multi();operations.opsForValue().set("message_key", "message");operations.opsForSet().add("message_ids_key", "message_id");operations.exec();return null;}
});
// 处理事务消息
redisTemplate.execute(new SessionCallback<Void>() {@Overridepublic Void execute(RedisOperations operations) throws DataAccessException {operations.watch("message_ids_key");Set<String> messageIds = operations.opsForSet().members("message_ids_key");if (messageIds.contains("message_id")) {operations.multi();// 处理消息operations.opsForValue().get("message_key");operations.opsForSet().remove("message_ids_key", "message_id");operations.exec();}return null;}
});

##20、分布式锁实现限流:使用Redis实现分布式锁实现限流功能,控制请求流量。

// 尝试加锁
Boolean locked = redisTemplate.opsForValue().setIfAbsent("lock_key", "lock_value", Duration.ofSeconds(30));
if (locked) {try {// 限制每秒最多处理10个请求String key = "limit_key:" + System.currentTimeMillis() / 1000;Long count = redisTemplate.opsForValue().increment(key, 1);if (count == 1) {redisTemplate.expire(key, 1, TimeUnit.SECONDS);} else if (count > 10) {throw new RuntimeException("too many requests");}} finally {// 释放锁redisTemplate.delete("lock_key");}
}

##21、分布式锁实现幂等性:使用Redis实现分布式锁实现幂等性,避免重复操作。

// 尝试加锁
Boolean locked = redisTemplate.opsForValue().setIfAbsent("lock_key", "lock_value", Duration.ofSeconds(30));
if (locked) {try {// 检查是否已经处理过String key = "processed_key:" + id;Boolean processed = redisTemplate.opsForValue().get(key) != null;if (!processed) {// 处理数据processData();// 标记为已处理redisTemplate.opsForValue().set(key, "processed", Duration.ofDays(1));}} finally {// 释放锁redisTemplate.delete("lock_key");}
}

##22、分布式事务消息实现幂等性:使用Redis实现分布式事务消息实现幂等性,避免重复操作。

// 提交事务消息
redisTemplate.execute(new SessionCallback<Void>() {@Overridepublic Void execute(RedisOperations operations) throws DataAccessException {operations.watch("message_ids_key");Set<String> messageIds = operations.opsForSet().members("message_ids_key");if (!messageIds.contains("message_id")) {operations.multi();// 提交消息operations.opsForValue().set("message_key", "message");operations.opsForSet().add("message_ids_key", "message_id");operations.exec();}return null;}
});
// 处理事务消息
redisTemplate.execute(new SessionCallback<Void>() {@Overridepublic Void execute(RedisOperations operations) throws DataAccessException {operations.watch("message_ids_key");Set<String> messageIds = operations.opsForSet().members("message_ids_key");if (messageIds.contains("message_id")) {operations.multi();// 处理消息operations.opsForValue().get("message_key");operations.opsForSet().remove("message_ids_key", "message_id");operations.exec();}return null;}
});

##23、分布式缓存更新实现幂等性:使用Redis实现分布式缓存更新实现幂等性,避免重复操作。

// 尝试加锁
Boolean locked = redisTemplate.opsForValue().setIfAbsent("lock_key", "lock_value", Duration.ofSeconds(30));
if (locked) {try {// 检查是否已经处理过String key = "processed_key:" + id;Boolean processed = redisTemplate.opsForValue().get(key) != null;if (!processed) {// 更新数据updateData();// 将缓存标记为失效redisTemplate.delete("cache_key");// 标记为已处理redisTemplate.opsForValue().set(key, "processed", Duration.ofDays(1));}} finally {// 释放锁redisTemplate.delete("lock_key");}
}

##24、分布式事务消息实现延迟处理:

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;public class DelayedMessageQueue {private JedisPool jedisPool;public DelayedMessageQueue() {JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();jedisPoolConfig.setMaxTotal(100);jedisPoolConfig.setMaxIdle(20);jedisPoolConfig.setMinIdle(10);jedisPoolConfig.setTestOnBorrow(true);jedisPool = new JedisPool(jedisPoolConfig, "localhost", 6379);}public void addMessage(String message, long delay) {try (Jedis jedis = jedisPool.getResource()) {long timestamp = System.currentTimeMillis() + delay;jedis.zadd("delayed_messages", timestamp, message);}}public void processMessages() {try (Jedis jedis = jedisPool.getResource()) {while (true) {long timestamp = System.currentTimeMillis();// 获取所有需要处理的消息Set<String> messages = jedis.zrangeByScore("delayed_messages", 0, timestamp, 0, 1);if (messages.isEmpty()) {// 没有需要处理的消息,等待一段时间再次尝试Thread.sleep(1000);continue;}String message = messages.iterator().next();// 处理消息System.out.println("Processing message: " + message);// 从延迟消息队列中删除已经处理的消息jedis.zrem("delayed_messages", message);}} catch (InterruptedException e) {Thread.currentThread().interrupt();}}public static void main(String[] args) {DelayedMessageQueue messageQueue = new DelayedMessageQueue();messageQueue.addMessage("Hello, world!", 5000); // 5秒后处理消息messageQueue.processMessages();}
}

这个样例代码中,我们使用了Redis的有序集合来实现延迟消息队列。当我们添加消息时,我们将消息和一个时间戳加入到有序集合中,
时间戳为当前时间加上延迟时间。在处理消息时,我们获取所有需要处理的消息,即时间戳小于当前时间的所有消息,然后依次处理它们,
并从延迟消息队列中删除已经处理的消息。如果没有需要处理的消息,我们等待一段时间再次尝试。

相关文章:

java语言里redis在项目中使用场景,每个场景的样例代码

Redis是一款高性能的NoSQL数据库&#xff0c;常被用于缓存、消息队列、计数器、分布式锁等场景。以下是50个Redis在项目中使用的场景以及对应的样例代码和详细说明&#xff1a; ##1、缓存&#xff1a;将查询结果缓存在Redis中&#xff0c;下次查询时直接从缓存中获取&#xff…...

Mongo集合操作

2、创建切换数据库 2.1 默认数据库 mongo数据库和其他类型的数据库一样&#xff0c;可以创建数据库&#xff0c;且可以创建多个数据库。 mongo数据库默认会有四个数据库&#xff0c;分别是 admin&#xff1a;主要存储MongoDB的用户、角色等信息 config&#xff1a;主要存储…...

ConvTranspose2d 的简单例子理解

文章目录 参考基础概念output_padding 简单例子&#xff1a; stride2step1step2step3 参考 逆卷积的详细解释ConvTranspose2d&#xff08;fractionally-strided convolutions)nn.ConvTranspose2d的参数output_padding的作用torch.nn.ConvTranspose2d Explained 基础概念 逆卷…...

酒精和肠内外健康:有帮助还是有害?

谷禾健康 酒精与健康 饮酒作为一种特殊的文化形式&#xff0c;在我们国家有其独特的地位&#xff0c;在几千年的发展中&#xff0c;酒几乎渗透到日常生活、社会经济、文化活动之中。 据2018年发表的《中国饮酒人群适量饮酒状况》白皮书数据显示&#xff0c;中国饮酒人群高达6亿…...

SylixOS Shell下操作环境变量方法

系统启动后会在内核中生成一份默认的环境变量&#xff0c;环境变量名和默认值由源程序决定。系统启动后如果文件系统中存在有效的/etc/profile文件&#xff0c;则还会自动读取文件中的内容&#xff0c;并导入到Shell环境中&#xff0c;覆盖对应变量或增加新的变量。程序运行时&…...

【dfs解决分组问题-两道例题——供佬学会!】(A元素是放在已经存在的组别中,还是再创建一个更好?--小孩子才做选择,dfs直接两种情况都试试)

问题关键就是&#xff1a; 一个点&#xff0c;可能 新开一个组 比 放到已经存在的组 更划算 因为后面的数据&#xff0c;我们遍历之前的点时&#xff0c;并不知道 所以我们应该针对每个点&#xff0c;都应该做出一个选择就是 新开一个元组或者放到之前的元组中&#xff0c;都尝…...

使用Hexo在Github上搭建个人博客

使用Hexo在Github上搭建个人博客 1. 安装Node和git2. 安装Hexo3. Git与Github的准备工作4. 将Hexo部署到Github5. 开始写作 1. 安装Node和git 在Mac上安装Node.js可以使用Homebrew&#xff0c;使用以下命令安装&#xff1a; brew install node使用以下命令安装Git&#xff1a; …...

【面试题】面试官:说说你对 CSS 盒模型的理解

前言 CSS 盒模型是 CSS 基础的重点难点&#xff0c;因此常被面试官们拿来考察候选人对前端基础的掌握程度&#xff0c;这篇文章将对 CSS 盒模型知识点进行全面的梳理。 我们先看个例子&#xff1a;下面的 div 元素的总宽度是多少呢&#xff1f; js <!DOCTYPE html> &…...

【ROS2】学习笔记

1. 基础概念 1.1 执行单元 1.1.1 executable——执行程序 executable表示针对某个目标的程序执行流程&#xff0c;一个executable可以启动多个node&#xff1b; 1.1.2 node——“进程” node其实就是进程的意思&#xff1b; ROS2允许同时启动两个相同的node&#xff0c;&a…...

Springboot +Flowable,流程表单应用之外置表单(JSON形式)(二)

一.简介 整体上来说&#xff0c;我们可以将Flowable 的表单分为三种不同的类型&#xff1a; 动态表单 这种表单定义方式我们可以配置表单中每一个字段的可读性、可写性、是否必填等信息&#xff0c;不过不能定义完整的表单页面。外置表单 外置表单我们只需要定义一下表单的 k…...

JavaScript如何使用if语句

JavaScript的if语句可以让我们根据某些条件来执行不同的代码块。使用if语句的基本思路是将要执行的代码放在括号内&#xff0c;并使用if关键字进行匹配。下面是一些例子&#xff1a; 简单的if语句&#xff1a; let age 18; if (age > 18) { console.log("You are…...

XSS攻击以及java应对措施

文章目录 一. XSS攻击介绍1. 前端安全2. xss攻击简介3. xss的攻击方式 二. java应对xss攻击的解决方案1. 强制修改html敏感标签内容2. 利用过滤器过滤非法html标签 一. XSS攻击介绍 1. 前端安全 随着互联网的高速发展&#xff0c;信息安全问题已经成为企业最为关注的焦点之一…...

yolo 训练

这里写目录标题 分配训练集&Validation数量数据集读取读取全部文件夹替换路径 loss weightNMSBBox_IOUEIou Optimizer 分配训练集&Validation数量 validation_size training_size * validation_ratio / (1 - validation_ratio)training_size 219 validation_ratio …...

谷歌chrome浏览器升级新版后字体显示不清楚解决方案

谷歌chrome浏览器升级新版后字体显示不清楚解决方案 参考图片&#xff1a; Chrome更新至版本Chrome 109.0.5414.120 字体看不清 浏览器症状与表现 Chrome更新至版本Chrome 109.0.5414.120 字体看不清&#xff1b;会很细&#xff0c;在设置中选择自定义的字体&#xff0c;仍无法…...

在外包干了三年,我废了……不吹不黑!

没错&#xff0c;我也干过外包&#xff0c;一干就是三年&#xff0c;三年后&#xff0c;我废了…… 虽说废的不是很彻底&#xff0c;但那三年我几乎是出差了三年、玩了三年、荒废了三年&#xff0c;那三年&#xff0c;我的技术能力几乎是零成长的。 说起这段三年的外包经历&a…...

【Vue】学习笔记-消息的订阅与发布

消息的订阅与发布(基本不用) 消息订阅与发布(pubsub)消息订阅与发布是一种组件间的通信的方式&#xff0c;适用于任意组件间通信 消息订阅与发布 1.订阅消息∶消息名 2.发布消息︰消息内容 消息订阅与发布的工作流程&#xff1a; &#xff08;A是订阅者&#xff0c;B是发布…...

大疆无人机 MobileSDK(遥控器/手机端)开发 v5版<1>

文章目录 概要整体架构流程技术细节SDK 架构体系概述层级架构智能任务空白项目集成 MSDK新建空白项目新建 MyApplication.kt 文件修改 build.gradle(Module) 文件修改 AndroidManifest.xml 文件修改 MainActivity.kt 文件导入 UXSDK 开源框架4.X 和 5.X 版本差异说明DJIKey差异…...

azkaban介绍

目录 为什么需要工作流调度系统 什么是azkaban azkaban适用场景 azkaban特点 常见的工作流调度系统 azkaban和Ooize特性对比 azkaban的架构 azkaban调度的任务有可能有那些类型 总结 为什么需要工作流调度系统 一个完整的大数据分析系统&#xff0c;必然由很多任务单…...

自学黑客(网络安全)必学内容

随着时代的发展&#xff0c;经济、社会、生产、生活越来越依赖网络。而随着万物互联的物联网技术的兴起&#xff0c;线上线下已经打通&#xff0c;虚拟世界和现实世界的边界正变得模糊。这使得来自网络空间的攻击能够穿透虚拟世界的边界&#xff0c;直接影响现实世界的安全。 …...

Java每日一练(20230518) 移除元素、跳跃游戏II、复原IP地址

目录 1. 移除链表元素 &#x1f31f; 2. 跳跃游戏 II &#x1f31f;&#x1f31f; 3. 复原 IP 地址 &#x1f31f;&#x1f31f; &#x1f31f; 每日一练刷题专栏 &#x1f31f; Golang每日一练 专栏 Python每日一练 专栏 C/C每日一练 专栏 Java每日一练 专栏 1. 移…...

XCTF-web-easyupload

试了试php&#xff0c;php7&#xff0c;pht&#xff0c;phtml等&#xff0c;都没有用 尝试.user.ini 抓包修改将.user.ini修改为jpg图片 在上传一个123.jpg 用蚁剑连接&#xff0c;得到flag...

树莓派超全系列教程文档--(62)使用rpicam-app通过网络流式传输视频

使用rpicam-app通过网络流式传输视频 使用 rpicam-app 通过网络流式传输视频UDPTCPRTSPlibavGStreamerRTPlibcamerasrc GStreamer 元素 文章来源&#xff1a; http://raspberry.dns8844.cn/documentation 原文网址 使用 rpicam-app 通过网络流式传输视频 本节介绍来自 rpica…...

JavaScript 中的 ES|QL:利用 Apache Arrow 工具

作者&#xff1a;来自 Elastic Jeffrey Rengifo 学习如何将 ES|QL 与 JavaScript 的 Apache Arrow 客户端工具一起使用。 想获得 Elastic 认证吗&#xff1f;了解下一期 Elasticsearch Engineer 培训的时间吧&#xff01; Elasticsearch 拥有众多新功能&#xff0c;助你为自己…...

mysql已经安装,但是通过rpm -q 没有找mysql相关的已安装包

文章目录 现象&#xff1a;mysql已经安装&#xff0c;但是通过rpm -q 没有找mysql相关的已安装包遇到 rpm 命令找不到已经安装的 MySQL 包时&#xff0c;可能是因为以下几个原因&#xff1a;1.MySQL 不是通过 RPM 包安装的2.RPM 数据库损坏3.使用了不同的包名或路径4.使用其他包…...

Android 之 kotlin 语言学习笔记三(Kotlin-Java 互操作)

参考官方文档&#xff1a;https://developer.android.google.cn/kotlin/interop?hlzh-cn 一、Java&#xff08;供 Kotlin 使用&#xff09; 1、不得使用硬关键字 不要使用 Kotlin 的任何硬关键字作为方法的名称 或字段。允许使用 Kotlin 的软关键字、修饰符关键字和特殊标识…...

Mac下Android Studio扫描根目录卡死问题记录

环境信息 操作系统: macOS 15.5 (Apple M2芯片)Android Studio版本: Meerkat Feature Drop | 2024.3.2 Patch 1 (Build #AI-243.26053.27.2432.13536105, 2025年5月22日构建) 问题现象 在项目开发过程中&#xff0c;提示一个依赖外部头文件的cpp源文件需要同步&#xff0c;点…...

jmeter聚合报告中参数详解

sample、average、min、max、90%line、95%line,99%line、Error错误率、吞吐量Thoughput、KB/sec每秒传输的数据量 sample&#xff08;样本数&#xff09; 表示测试中发送的请求数量&#xff0c;即测试执行了多少次请求。 单位&#xff0c;以个或者次数表示。 示例&#xff1a;…...

打手机检测算法AI智能分析网关V4守护公共/工业/医疗等多场景安全应用

一、方案背景​ 在现代生产与生活场景中&#xff0c;如工厂高危作业区、医院手术室、公共场景等&#xff0c;人员违规打手机的行为潜藏着巨大风险。传统依靠人工巡查的监管方式&#xff0c;存在效率低、覆盖面不足、判断主观性强等问题&#xff0c;难以满足对人员打手机行为精…...

PostgreSQL——环境搭建

一、Linux # 安装 PostgreSQL 15 仓库 sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-$(rpm -E %{rhel})-x86_64/pgdg-redhat-repo-latest.noarch.rpm# 安装之前先确认是否已经存在PostgreSQL rpm -qa | grep postgres# 如果存在&#xff0…...

【从零开始学习JVM | 第四篇】类加载器和双亲委派机制(高频面试题)

前言&#xff1a; 双亲委派机制对于面试这块来说非常重要&#xff0c;在实际开发中也是经常遇见需要打破双亲委派的需求&#xff0c;今天我们一起来探索一下什么是双亲委派机制&#xff0c;在此之前我们先介绍一下类的加载器。 目录 ​编辑 前言&#xff1a; 类加载器 1. …...