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

Redis数据库 | 事务、持久化

在这里插入图片描述

💗wei_shuo的个人主页

💫wei_shuo的学习社区

🌐Hello World !


Redis事务操作

Redis事务是一组命令的集合,这些命令会作为一个整体被执行,要么全部执行成功,要么全部执行失败;Redis事务通过MULTI、EXEC、DISCARD和WATCH四个命令来实现

MULTI:开启一个新的事务

EXEC:提交事务

DISCARD:取消事务

WATCH:监控一个或多个键,当这些键被其他客户端修改时,当前事务会被中断

Redis乐观锁

乐观锁是一种并发控制机制,它假设冲突的概率比较小,因此不会在访问共享资源时加锁,而是在更新时检查数据是否被其他进程修改过

Redis悲观锁

悲观锁是指在对共享资源进行操作时,认为其他线程或进程会对该资源进行修改,因此在操作前先加锁,以防止其他线程或进程的干扰

Jedis

Jedis是一个Java语言编写的Redis客户端库,用于在Java应用程序中连接和操作Redis数据库;Jedis库是开源的,可以通过Maven或Gradle等构建工具进行引入和使用

<dependency><groupId>com.github.luues.boot</groupId><artifactId>spring-boot-starter-jedis</artifactId><version>1.0.3.5.RELEASE</version>
</dependency>

Springboot集成Redis

  • 依赖导入
		<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis</artifactId></dependency>
  • application.properties
#配置Redis
spring.redis.host=127.0.0.1
spring.redis.port=6379
  • 测试
package com.wei;import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.core.RedisTemplate;@SpringBootTest
class SpringbootRedisApplicationTests {@Autowired(required = false)private RedisTemplate redisTemplate;@Testvoid contextLoads() {/*** RedisTemplate    操作不同是数据类型* opsForValue  操作String* opsForList   操作List* opsForHash   操作Hash* ……*//*** 操作数据库连接* redisTemplate.getConnectionFactory().getConnection();*/RedisConnection connection = redisTemplate.getConnectionFactory().getConnection();/*connection.flushDb(); 用于刷新查询缓存和结果集合,以提高查询性能connection.flushAll(); 用于刷新整个数据库,包括所有的表、视图、存储过程和触发器等*/connection.flushDb();connection.flushAll();}}
package com.wei;import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.core.RedisTemplate;@SpringBootTest
class SpringbootRedisApplicationTests {@Autowired(required = false)private RedisTemplate redisTemplate;@Testvoid contextLoads() {/*** RedisTemplate    操作不同是数据类型* opsForValue  操作String* opsForList   操作List* opsForHash   操作Hash* ……*/redisTemplate.opsForValue().set("mykey","weishuo");System.out.println(redisTemplate.opsForValue().get("mykey"));}}

源码

  • RedisAutoConfiguration.java
package org.springframework.boot.autoconfigure.data.redis;import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnSingleCandidate;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;@AutoConfiguration
@ConditionalOnClass({RedisOperations.class})
@EnableConfigurationProperties({RedisProperties.class})
@Import({LettuceConnectionConfiguration.class, JedisConnectionConfiguration.class})
public class RedisAutoConfiguration {public RedisAutoConfiguration() {}@Bean@ConditionalOnMissingBean(name = {"redisTemplate"})@ConditionalOnSingleCandidate(RedisConnectionFactory.class)public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {RedisTemplate<Object, Object> template = new RedisTemplate();template.setConnectionFactory(redisConnectionFactory);return template;}@Bean@ConditionalOnMissingBean@ConditionalOnSingleCandidate(RedisConnectionFactory.class)public StringRedisTemplate stringRedisTemplate(RedisConnectionFactory redisConnectionFactory) {return new StringRedisTemplate(redisConnectionFactory);}
}
  • RedisProperties.java
public class RedisProperties {private int database = 0;private String url;private String host = "localhost";private String username;private String password;private int port = 6379;private boolean ssl;private Duration timeout;private Duration connectTimeout;private String clientName;private RedisProperties.ClientType clientType;private RedisProperties.Sentinel sentinel;private RedisProperties.Cluster cluster;private final RedisProperties.Jedis jedis = new RedisProperties.Jedis();private final RedisProperties.Lettuce lettuce = new RedisProperties.Lettuce();……
}

自定义配置类

  • config/RedisConfig.java
package com.wei.config;import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;import java.net.UnknownHostException;@Configuration
@SuppressWarnings("all")
//镇压所有警告
public class RedisConfig {@Beanpublic RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory)throws UnknownHostException {
//      默认的连接配置,和源码保持一致即可RedisTemplate<String, Object> template = new RedisTemplate<>();template.setConnectionFactory(redisConnectionFactory);//        序列化配置
//        json序列化配置--JacksonJackson2JsonRedisSerializer<Object> objectJackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<>(Object.class);ObjectMapper objectMapper = new ObjectMapper();objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);objectJackson2JsonRedisSerializer.setObjectMapper(objectMapper);//       string的序列化StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();//       string的key和hash的key都采用string的序列化
//        value都采用Jackson的序列化//key采用string序列化方式template.setKeySerializer(stringRedisSerializer);//hash的key采用string序列化方式template.setHashKeySerializer(stringRedisSerializer);//value采用Jackson序列化方式template.setValueSerializer(objectJackson2JsonRedisSerializer);//hash的value采用Jackson序列化方式template.setHashValueSerializer(objectJackson2JsonRedisSerializer);return template;}
}

Redis工具类封装

utils/RedisUtil.java

package com.wei.utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;import java.util.*;
import java.util.concurrent.TimeUnit;
@Component
public final class RedisUtil {@Autowiredprivate RedisTemplate<String, Object> redisTemplate;
// =============================common============================/*** 指定缓存失效时间* @param key 键* @param time 时间(秒)*/public boolean expire(String key, long time) {try {if (time > 0) {redisTemplate.expire(key, time, TimeUnit.SECONDS);}return true;} catch (Exception e) {e.printStackTrace();return false;}}/*** 根据key 获取过期时间* @param key 键 不能为null* @return 时间(秒) 返回0代表为永久有效*/public long getExpire(String key) {return redisTemplate.getExpire(key, TimeUnit.SECONDS);}/*** 判断key是否存在* @param key 键* @return true 存在 false不存在*/public boolean hasKey(String key) {try {return redisTemplate.hasKey(key);} catch (Exception e) {e.printStackTrace();return false;}}/*** 删除缓存* @param key 可以传一个值 或多个*/@SuppressWarnings("unchecked")public void del(String... key) {if (key != null && key.length > 0) {if (key.length == 1) {redisTemplate.delete(key[0]);} else {redisTemplate.delete((Collection<String>) CollectionUtils.arrayToList(key));}}}
// ============================String=============================/*** 普通缓存获取* @param key 键* @return 值*/public Object get(String key) {return key == null ? null : redisTemplate.opsForValue().get(key);}/*** 普通缓存放入* @param key 键* @param value 值* @return true成功 false失败*/public boolean set(String key, Object value) {try {redisTemplate.opsForValue().set(key, value);return true;} catch (Exception e) {e.printStackTrace();return false;}}/*** 普通缓存放入并设置时间* @param key 键* @param value 值* @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期* @return true成功 false 失败*/public boolean set(String key, Object value, long time) {try {if (time > 0) {redisTemplate.opsForValue().set(key, value, time,TimeUnit.SECONDS);} else {set(key, value);}return true;} catch (Exception e) {e.printStackTrace();return false;}}/*** 递增* @param key 键* @param delta 要增加几(大于0)*/public long incr(String key, long delta) {if (delta < 0) {throw new RuntimeException("递增因子必须大于0");}return redisTemplate.opsForValue().increment(key, delta);}/*** 递减* @param key 键* @param delta 要减少几(小于0)*/public long decr(String key, long delta) {if (delta < 0) {throw new RuntimeException("递减因子必须大于0");}return redisTemplate.opsForValue().increment(key, -delta);}
// ================================Map=================================/*** HashGet* @param key 键 不能为null* @param item 项 不能为null*/public Object hget(String key, String item) {return redisTemplate.opsForHash().get(key, item);}/*** 获取hashKey对应的所有键值* @param key 键* @return 对应的多个键值*/public Map<Object, Object> hmget(String key) {return redisTemplate.opsForHash().entries(key);}/*** HashSet* @param key 键* @param map 对应多个键值*/public boolean hmset(String key, Map<String, Object> map) {try {redisTemplate.opsForHash().putAll(key, map);return true;} catch (Exception e) {e.printStackTrace();return false;}}/*** HashSet 并设置时间* @param key 键* @param map 对应多个键值* @param time 时间(秒)* @return true成功 false失败*/public boolean hmset(String key, Map<String, Object> map, long time) {try {redisTemplate.opsForHash().putAll(key, map);if (time > 0) {expire(key, time);}return true;} catch (Exception e) {e.printStackTrace();return false;}}/*** 向一张hash表中放入数据,如果不存在将创建** @param key 键* @param item 项* @param value 值* @return true 成功 false失败*/public boolean hset(String key, String item, Object value) {try {redisTemplate.opsForHash().put(key, item, value);return true;} catch (Exception e) {e.printStackTrace();return false;}}/*** 向一张hash表中放入数据,如果不存在将创建** @param key 键* @param item 项* @param value 值* @param time 时间(秒) 注意:如果已存在的hash表有时间,这里将会替换原有的时间* @return true 成功 false失败*/public boolean hset(String key, String item, Object value, long time) {try {redisTemplate.opsForHash().put(key, item, value);if (time > 0) {expire(key, time);}return true;} catch (Exception e) {e.printStackTrace();return false;}}/*** 删除hash表中的值** @param key 键 不能为null* @param item 项 可以使多个 不能为null*/public void hdel(String key, Object... item) {redisTemplate.opsForHash().delete(key, item);}/*** 判断hash表中是否有该项的值** @param key 键 不能为null* @param item 项 不能为null* @return true 存在 false不存在*/public boolean hHasKey(String key, String item) {return redisTemplate.opsForHash().hasKey(key, item);}/*** hash递增 如果不存在,就会创建一个 并把新增后的值返回** @param key 键* @param item 项* @param by 要增加几(大于0)*/public double hincr(String key, String item, double by) {return redisTemplate.opsForHash().increment(key, item, by);}/*** hash递减** @param key 键* @param item 项* @param by 要减少记(小于0)*/public double hdecr(String key, String item, double by) {return redisTemplate.opsForHash().increment(key, item, -by);}
// ============================set=============================/*** 根据key获取Set中的所有值* @param key 键*/public Set<Object> sGet(String key) {try {return redisTemplate.opsForSet().members(key);} catch (Exception e) {e.printStackTrace();return null;}}/*** 根据value从一个set中查询,是否存在** @param key 键* @param value 值* @return true 存在 false不存在*/public boolean sHasKey(String key, Object value) {try {return redisTemplate.opsForSet().isMember(key, value);} catch (Exception e) {e.printStackTrace();return false;}}/*** 将数据放入set缓存** @param key 键* @param values 值 可以是多个* @return 成功个数*/public long sSet(String key, Object... values) {try {return redisTemplate.opsForSet().add(key, values);} catch (Exception e) {e.printStackTrace();return 0;}}/*** 将set数据放入缓存** @param key 键* @param time 时间(秒)* @param values 值 可以是多个* @return 成功个数*/public long sSetAndTime(String key, long time, Object... values) {try {Long count = redisTemplate.opsForSet().add(key, values);if (time > 0)expire(key, time);return count;} catch (Exception e) {e.printStackTrace();return 0;}}/*** 获取set缓存的长度** @param key 键*/public long sGetSetSize(String key) {try {return redisTemplate.opsForSet().size(key);} catch (Exception e) {e.printStackTrace();return 0;}}/*** 移除值为value的** @param key 键* @param values 值 可以是多个* @return 移除的个数*/public long setRemove(String key, Object... values) {try {Long count = redisTemplate.opsForSet().remove(key, values);return count;} catch (Exception e) {e.printStackTrace();return 0;}}
// ===============================list=================================/*** 获取list缓存的内容** @param key 键* @param start 开始* @param end 结束 0 到 -1代表所有值*/public List<Object> lGet(String key, long start, long end) {try {return redisTemplate.opsForList().range(key, start, end);} catch (Exception e) {e.printStackTrace();return null;}}/*** 获取list缓存的长度** @param key 键*/public long lGetListSize(String key) {try {return redisTemplate.opsForList().size(key);} catch (Exception e) {e.printStackTrace();return 0;}}/*** 通过索引 获取list中的值** @param key 键* @param index 索引 index>=0时, 0 表头,1 第二个元素,依次类推;index<0时,-1,表尾,-2倒数第二个元素,依次类推*/public Object lGetIndex(String key, long index) {try {return redisTemplate.opsForList().index(key, index);} catch (Exception e) {e.printStackTrace();return null;}}/*** 将list放入缓存** @param key 键* @param value 值*/public boolean lSet(String key, Object value) {try {redisTemplate.opsForList().rightPush(key, value);return true;} catch (Exception e) {e.printStackTrace();return false;}}/*** 将list放入缓存* @param key 键* @param value 值* @param time 时间(秒)*/public boolean lSet(String key, Object value, long time) {try {redisTemplate.opsForList().rightPush(key, value);if (time > 0)expire(key, time);return true;} catch (Exception e) {e.printStackTrace();return false;}}/*** 将list放入缓存** @param key 键* @param value 值* @return*/public boolean lSet(String key, List<Object> value) {try {redisTemplate.opsForList().rightPushAll(key, value);return true;} catch (Exception e) {e.printStackTrace();return false;}}/*** 将list放入缓存** @param key 键* @param value 值* @param time 时间(秒)* @return*/public boolean lSet(String key, List<Object> value, long time) {try {redisTemplate.opsForList().rightPushAll(key, value);if (time > 0)expire(key, time);return true;} catch (Exception e) {e.printStackTrace();return false;}}/*** 根据索引修改list中的某条数据** @param key 键* @param index 索引* @param value 值* @return*/public boolean lUpdateIndex(String key, long index, Object value) {try {redisTemplate.opsForList().set(key, index, value);return true;} catch (Exception e) {e.printStackTrace();return false;}}/*** 移除N个值为value** @param key 键* @param count 移除多少个* @param value 值* @return 移除的个数*/public long lRemove(String key, long count, Object value) {try {Long remove = redisTemplate.opsForList().remove(key, count,value);return remove;} catch (Exception e) {e.printStackTrace();return 0;}}
}

Redis持久化

Redis 持久化的主要作用是将 Redis 的数据持久化到磁盘中,以防止 Redis 在内存中的数据意外丢失或者系统宕机导致的数据丢失,保证数据的可靠性和持久性;Redis 提供了两种持久化方式,分别是 RDB 和 AOF

RDB持久化

RDB 持久化:将 Redis 在内存中的数据定期写入磁盘中的快照文件,可以通过配置定期保存快照的时间间隔,也可以手动执行保存操作;RDB 持久化的优点是占用内存小,恢复数据速度快,适用于数据量较大,但是对数据实时性要求不高的场景

在这里插入图片描述

AOF持久化

AOF 持久化:将 Redis 的所有写操作都记录在一个日志文件中,可以通过配置日志文件的同步方式,确保数据的可靠性和实时性。AOF 持久化的优点是数据实时性高,可靠性强,适用于数据对实时性要求较高的场景

在这里插入图片描述


🌼 结语:创作不易,如果觉得博主的文章赏心悦目,还请——点赞👍收藏⭐️评论📝


在这里插入图片描述

相关文章:

Redis数据库 | 事务、持久化

&#x1f497;wei_shuo的个人主页 &#x1f4ab;wei_shuo的学习社区 &#x1f310;Hello World &#xff01; Redis事务操作 Redis事务是一组命令的集合&#xff0c;这些命令会作为一个整体被执行&#xff0c;要么全部执行成功&#xff0c;要么全部执行失败&#xff1b;Redis事…...

浅析大数据时代下的视频技术发展趋势以及AI加持下视频场景应用

视频技术的发展可以追溯到19世纪初期的早期实验。到20世纪初期&#xff0c;电视技术的发明和普及促进了视频技术的进一步发展。 1&#xff09;数字化&#xff1a;数字化技术的发明和发展使得视频技术更加先进。数字电视信号具有更高的清晰度和更大的带宽&#xff0c;可以更快地…...

TensorRT学习笔记--基于YoloV8检测图片和视频

1--完整项目 完整项目地址&#xff1a;https://github.com/liujf69/TensorRT-Demo git clone https://github.com/liujf69/TensorRT-Demo.gitcd TRT_YoloV8 2--模型转换 cd yolov8python gen_wts.py 3--编译项目 mkdir buildcd build cmake .. # 需要更改 CMakeLists.txt…...

【C++】开源:matplotlib-cpp静态图表库配置与使用

&#x1f60f;★,:.☆(&#xffe3;▽&#xffe3;)/$:.★ &#x1f60f; 这篇文章主要介绍matplotlib-cpp图表库配置与使用。 无专精则不能成&#xff0c;无涉猎则不能通。——梁启超 欢迎来到我的博客&#xff0c;一起学习&#xff0c;共同进步。 喜欢的朋友可以关注一下&…...

香港IT软件开发服务公司Alpha Technology 申请纳斯达克IPO上市

来源&#xff1a;猛兽财经 作者&#xff1a;猛兽财经 猛兽财经获悉&#xff0c;总部位于中国香港的IT软件开发服务公司Alpha Technology 近期已向美国证券交易委员会&#xff08;SEC&#xff09;提交招股书&#xff0c;申请在纳斯达克IPO上市&#xff0c;股票代码为&#xff0…...

JavaScript:数组深拷贝

文章目录 1 数组深拷贝的意义2 数组深拷贝的常用方式2.1 使用 JSON 序列化和反序列化2.2 使用递归方法2.3 使用第三方库 1 数组深拷贝的意义 JavaScript中的数组深拷贝&#xff0c;指的是创建一个完全独立于原始数组的新数组&#xff0c;所有新数组的元素都是原始数组的副本。…...

干翻Dubbo系列第七篇:@EnableDubbo、@DubboService、@DubboReference注解的作用

文章目录 文章说明 一&#xff1a;EnableDubbo注解的作用 1&#xff1a;注解使用地点 2&#xff1a;注解作用 3&#xff1a;路径要求 4&#xff1a;指定路径 5&#xff1a;另外一种指定路径 二&#xff1a;DubboService注解的作用 1&#xff1a;注解作用 2&#xff1…...

clickhouse断电重启故障解决方案

业务场景 公司的一个日志系统用到了clickhouse。一线运维反映说有个生产环境因为异常断电造成服务器重启。在执行日志系统的启动脚本时&#xff0c;一直报clickhouse启动不起来&#xff0c;日志系统无法使用。 问题排查 通过阅读启动脚本代码&#xff0c;以及启动日志系统&a…...

Spring学习笔记之Bean的实例化方式

文章目录 通过构造方法实例化通过简单工厂模式实例化通过factory-bean实例化BeanFactory和FactoryBean的区别BeanFactoryFactoryBean 注入自定义Date Spring为Bean提供了多种实例化方式&#xff0c;通常包括4种方式。&#xff08;也就是说在Spring中为Bean对象的创建准备了很多…...

JVM-类加载器

1.前置知识 1.1CPU与内存交互图&#xff1a; 2.类加载器ClassLoader 在装载(Load)阶段&#xff0c;其中第(1)步:通过类的全限定名获取其定义的二进制字节流&#xff0c;需要借助类装 载器完成&#xff0c;顾名思义&#xff0c;就是用来装载Class文件的。 2.1什么是类加载器&a…...

ChatGPT在法律行业的市场潜力

​ChatGPT现在已经成为我们的文字生成辅助工具、搜索引擎助手&#xff0c;许多体验过它的朋友会发现对它越来越依赖&#xff0c;并将其逐渐融入到自己的日常工作、生活。但有一点值得注意&#xff1a;这种人工智能除了技术可行、经济价值可行还要与相关规范即人类普遍的价值观念…...

Python编程从入门到实践练习第三章:列表简介

目录 一、字符串1.1 在字符串中使用变量 二、列表2.1 遍历列表练习题代码 2.2 列表元素的插入和删除涉及方法练习题代码 2.3 组织列表涉及方法练习题代码 2.4 索引 参考书&#xff1a;Python从入门到实践&#xff08;第二版&#xff09; 一、字符串 1.1 在字符串中使用变量 f…...

【Spring Boot】请求参数传json数组,后端采用(pojo)新增案例(103)

请求参数传json数组&#xff0c;后端采用&#xff08;pojo&#xff09;接收的前提条件&#xff1a; 1.pom.xml文件加入坐标依赖&#xff1a;jackson-databind 2.Spring Boot 的启动类加注解&#xff1a;EnableWebMvc 3.Spring Boot 的Controller接受参数采用&#xff1a;Reque…...

Redis 持久化RDB和AOF

Redis 持久化之RDB和AOF Redis 有两种持久化方案&#xff0c;RDB &#xff08;Redis DataBase&#xff09;和 AOF &#xff08;Append Only File&#xff09;。如果你想快速了解和使用RDB和AOF&#xff0c;可以直接跳到文章底部看总结。本章节通过配置文件&#xff0c;触发快照…...

【ThinkPHP】PHP实现分页功能

查询列表数据&#xff0c;需要用到分页功能&#xff0c;下面是分页功能的代码&#xff1a; /*** Summary of userList* return \think\response\Json*/public function userList(){$page input("page")?:1;//当前页数$size input("size")?:10;//每页大…...

chrome 插件开发

参考&#xff1a; https://www.cnblogs.com/amboke/p/16718855.html 设计和实现一个 Chrome 插件提升登录效率_若川的技术博客_51CTO博客 最新版 V3 chrome 插件开发~ demo 坑 - 掘金 官方文档&#xff1a;https://developer.chrome.com/docs/extensions/...

开源MinDoc wiki系统搭建

部署文档参考 https://cloud.tencent.com/developer/beta/article/2134667 https://mp.weixin.qq.com/s?__bizMzU0MzEyODAyNA&mid2247485475&idx1&snac5ac76beac0a1405ca7a0f045f44db3&chksmfb116894cc66e182b197601420b8b5409a91ac538ba67d01248659de913fe7…...

pytest.ini 文件说明

pytest.ini 文件是用于配置 pytest 测试用例运行规则的文件。pytest.ini 配置文件支持的参数有以下几类&#xff1a; 匹配测试文件和测试函数的过滤参数测试用例执行参数测试报告输出参数临时文件及路径参数插件参数 以下是一些常见的 pytest.ini 配置参数及其用法示例&#…...

遥感、GIS、GPS在土壤空间数据分析、适应性评价、制图、土壤普查中怎样应用?

摸清我国当前土壤质量与完善土壤类型&#xff0c;可以为守住耕地红线、保护生态环境、优化农业生产布局、推进农业高质量发展奠定坚实基础&#xff0c;为此&#xff0c;2022年初国务院印发了《关于开展第三次全国土壤普查的通知》&#xff0c;决定自2022年起开展第三次全国土壤…...

git | git使用心得记录

公司里项目最近使用Git进行协作开发&#xff0c;总结一下使用心得 一、第一次用git&#xff0c;完全同步最新代码checkout 按照以下步骤操作 1、git init 2、git remote add origin 远程仓库的地址https://gitlab.xxxx.com.cn/xx/xx/xxx/Android/baseline/x.x.x.git(远程仓库…...

【卷积神经网络作业实现人脸的关键点定位功能】

下面是完成这道题目的代码&#xff1a;import os import cv2 import numpy as np import pandas as pd import torch import torch.nn as nn from torch.utils.data import Dataset,DataLoader from torchvision import transforms import matplotlib.pyplot as plt1. 数据集定…...

如何用Wi-Fi信号实现非接触检测:ESP-CSI完整指南

如何用Wi-Fi信号实现非接触检测&#xff1a;ESP-CSI完整指南 【免费下载链接】esp-csi Applications based on Wi-Fi CSI (Channel state information), such as indoor positioning, human detection 项目地址: https://gitcode.com/GitHub_Trending/es/esp-csi 想要让…...

5个技巧掌握DINO注意力可视化:从入门到模型可解释性分析

5个技巧掌握DINO注意力可视化&#xff1a;从入门到模型可解释性分析 【免费下载链接】dino PyTorch code for Vision Transformers training with the Self-Supervised learning method DINO 项目地址: https://gitcode.com/gh_mirrors/di/dino 视觉模型可解释性已成为人…...

cv2.findContours()错误的解决办法ValueError: not enough values to unpack (expected 3, got 2)

方法一&#xff1a;直接去掉一个返回值就即可。 方法二&#xff1a;把OpenCV 安装3.X的版本 具体原因 2、解析差异&#xff1a; OpenCV2和OpenCV4中&#xff1a; findContours这个轮廓提取函数会返回两个值&#xff1a;①轮廓的点集(contours)②各层轮廓的索引(hierarchy) 返回…...

NOR FLASH和NAND FLASH的对比

一、擦写寿命与数据可靠性 FLASH芯片的擦写次数一般来说都是有限的&#xff0c;目前主流产品的擦写寿命普遍在10万次左右。当FLASH芯片接近使用寿命终点时&#xff0c;写操作可能会出现失败。不过&#xff0c;需要注意NAND FLASH采用整块擦写机制&#xff0c;一旦块内出现一位数…...

Anubi基金会为何押注Cassava?深度解析Web3数据层+社交任务的黄金组合

Anubi基金会战略投资Cassava&#xff1a;Web3社交任务与数据层的价值重构 当Web3世界从DeFi的金融实验转向更广泛的社会化应用时&#xff0c;基础设施的演进正在经历一场静默的革命。Anubi基金会近期对Cassava Network的战略投资&#xff0c;揭示了两个关键趋势&#xff1a;社交…...

咱们今天聊点硬核但有趣的东西——用纳米级乐高积木(二氧化钛超表面)玩转光漩涡。想象一下,你手上有把能操控光波前形状的万能钥匙,这就是超表面的魅力所在

FDTD模型:基于超表面的完美涡旋光案例。 宽带任意阶 完美涡旋光束 介绍&#xff1a;全介质超表面实现完美矢量涡旋光束生成和完美庞加莱球生成&#xff0c;完美矢量涡旋光束不随拓扑荷的变化而变化&#xff0c;同时满足矢量光场的偏振变化&#xff0c;主要用于光学加密等领域&a…...

VRCT完全指南:在VRChat中打破语言障碍的终极解决方案

VRCT完全指南&#xff1a;在VRChat中打破语言障碍的终极解决方案 【免费下载链接】VRCT VRCT(VRChat Chatbox Translator & Transcription) 项目地址: https://gitcode.com/gh_mirrors/vr/VRCT VRCT&#xff08;VRChat Chatbox Translator & Transcription&…...

BT33F双基二极管的基本特性

简 介&#xff1a; 本文测试了BT33F双基二极管的特性&#xff0c;发现其发射极对两个基极呈现不同导通电压&#xff08;0.86V和1.6V&#xff09;&#xff0c;B1、B2间电阻约13KΩ。实验表明&#xff0c;只有当B1接地、B2接5V电源时&#xff0c;电路才能产生46Hz的振荡信号&…...

深入解析 iOS 上 fixed 底栏与滚动容器的手势冲突:从 H5 修复到原生根治

在移动端 H5 开发中,我们时常遇到这样的场景:页面底部有一个固定定位(position: fixed)的按钮栏或底栏,上方是一个可滚动的长列表。在 iOS 设备上,当用户尝试从底部 fixed 区域起手向上滑动时,列表却纹丝不动,仿佛被“粘”住了。这个现象不是偶发 bug,而是 iOS 对 fix…...