我在我的 api 中使用 spring data redis。我正在尝试通过 java 运行以下命令:
Set<String> union = redisTemplate.opsForSet().union(ids);
这导致请求中的 CROSSSLOT 键不会散列到同一插槽错误,因为我正在搜索的键位于不同的分片上。
我的 Redis 数据库模型具有我正在尝试查找的键的 SET 数据模型。
有什么方法 Lettuce 可以跨分片找到密钥,我可以避免这个错误。我的 LettuceConnectionFactory 是这样的:
@Bean
public LettuceConnectionFactory redisConnectionFactory() {
RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration();
redisStandaloneConfiguration.setPort(port);
redisStandaloneConfiguration.setHostName(host);
redisStandaloneConfiguration.setDatabase(database);
if (StringUtils.isNotBlank(password)) redisStandaloneConfiguration.setPassword(password);
LettuceClientConfiguration.LettuceClientConfigurationBuilder builder = LettuceClientConfiguration.builder();
if (useSSl) {
builder.useSsl();
}
LettuceClientConfiguration clientConfiguration = builder
.commandTimeout(Duration.ofSeconds(redisTimeoutMillis))
.clientOptions(ClientOptions
.builder()
.disconnectedBehavior(ClientOptions.DisconnectedBehavior.REJECT_COMMANDS)
.build())
.build();
LettuceConnectionFactory connectionFactory = new LettuceConnectionFactory(redisStandaloneConfiguration, clientConfiguration);
connectionFactory.afterPropertiesSet();
return connectionFactory;
}
@Bean
public RedisTemplate<String, Object> redisTemplate() {
RedisTemplate<String, Object> template = new RedisTemplate<>();
template.setConnectionFactory(redisConnectionFactory());
return template;
}
另外,是否可以避免联合操作并使用 org.springframework.data.repository.CrudRepository findAllByIds(ids) 获得相同的输出?
泰
经过大量研究后,我找到了一些关于为什么您在 Redis 中遇到此 CROSSSLOT 错误的信息。
有一个关于 CROSSSLOT KEYS 问题的很好的解释性博客here。请阅读它。
从该博客可以得出以下结论。
错误原因:
当您尝试执行涉及以下操作的操作时,会出现此错误 Redis Cluster 中有多个键,但这些键不属于 相同的哈希槽。
建议您可以采取的可能解决方案来缓解该问题:
使用单节点配置。这将确保所有密钥都位于单个节点中,从而完全消除 CROSSSLOT 密钥问题。
优化您的实体模型以减少多键操作的需要,因为 Redis 将无法维护这一点。
您可以在密钥内使用标签。 优点:假设您有多个密钥,现在您将它们附加到相同的标签,那么这将确保多个密钥进入同一个哈希槽,从而减少跨槽操作。
阅读博客以获取信息。
遵循下面给出的这些 Github 问题以供参考:
首先,不要被关键字“Spring OAuth2”的使用误导。这个问题和你面临的问题是一样的。
注意:槽!=碎片
我想提的主要事情是,多个哈希槽是由分片内的键创建的,并且不允许通过交叉操作从多个槽中获取它们。
现在,通过查看代码,我猜您很可能正在使用单节点配置。所以,请停止运行redis的集群模式。
现在来回答这个问题
另外,是否可以避免联合操作并使用 org.springframework.data.repository.CrudRepository findAllByIds(ids) 得到相同的输出?
是的,可以通过Redis-OM for Spring库和Redis Stack Server来实现,它具有搜索和查询的增强功能。
官方Redis-OM文档说:
Redis OM Spring 提供强大的存储库和自定义对象映射 构建在令人惊叹的 Spring Data Redis (SDR) 之上的抽象 框架。
现在,逐步进行:
注意:我使用 macOS、Java 17、Spring Boot 2.7.x 和 Redis 7.2.1 来演示这一点。
打开两个终端,分别在每个终端上运行 redis-stack-server 文件和 redis-cli 文件。
现在,在 CLI 模式下,输入命令
MONITOR
。开始跟踪 Redis 服务器上发生的任何活动。
来到代码库:
我借助他们的 Redis-OM Spring 散列教程来展示它是如何工作的
您需要将
redis-om-spring
和 spring-boot-starter-data-redis
作为依赖项包含在 POM 中。
pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.16</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>test-redis-spring</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>test-redis-spring</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.redis.om</groupId>
<artifactId>redis-om-spring</artifactId>
<version>0.6.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
创业班:
@SpringBootApplication
@EnableRedisEnhancedRepositories
public class TestRedisSpringApplication {
public static void main(String[] args) {
SpringApplication.run(TestRedisSpringApplication.class, args);
}
}
您必须使用
@EnableRedisEnhancedRepositories
使用基于 redis 的模型来检测存储库的存在。
存储库类:
@Repository
public interface PersonRepository extends CrudRepository<Person, String> {
}
实体类:
import com.redis.om.spring.annotations.Indexed;
import lombok.Data;
import lombok.NonNull;
import org.springframework.data.annotation.Id;
import org.springframework.data.redis.core.RedisHash;
@Data
@RedisHash
public class Person {
@Id
private String id;
@NonNull
@Indexed
private String fullName;
@NonNull
@Indexed
private String job;
}
注意:
@RedisHash
、@Indexed
是来自 Redis-OM lib 的注释,它与 Redis Stack Server 一起使用,因为它对普通 Redis Server 缺乏的搜索和查询具有广泛的支持。
自定义 Redis 配置,保证创建
JedisConnectionFactory
的 bean,从而将其提供给 Redis-OM,并且必须提供该 bean。
@Configuration
public class CustomRedisConfiguration {
@Bean
public JedisConnectionFactory jedisConnectionFactory() {
RedisStandaloneConfiguration redisConf = new RedisStandaloneConfiguration();
redisConf.setHostName("localhost");
redisConf.setPort(6379);
JedisClientConfiguration conf = JedisClientConfiguration.builder()
.readTimeout(Duration.ofMillis(1000))
.connectTimeout(Duration.ofMillis(1000))
.build();
return new JedisConnectionFactory(redisConf, conf);
}
}
服务器启动成功。
日志:
/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home/bin/java -javaagent:/Applications/IntelliJ IDEA CE.app/Contents/lib/idea_rt.jar=64359:/Applications/IntelliJ IDEA CE.app/Contents/bin -Dfile.encoding=UTF-8 -classpath /Users/anish/Downloads/test-redis-spring/target/classes:/Users/anish/.m2/repository/org/springframework/boot/spring-boot-starter-data-redis/2.7.16/spring-boot-starter-data-redis-2.7.16.jar:/Users/anish/.m2/repository/org/springframework/boot/spring-boot-starter/2.7.16/spring-boot-starter-2.7.16.jar:/Users/anish/.m2/repository/org/springframework/boot/spring-boot-starter-logging/2.7.16/spring-boot-starter-logging-2.7.16.jar:/Users/anish/.m2/repository/ch/qos/logback/logback-classic/1.2.12/logback-classic-1.2.12.jar:/Users/anish/.m2/repository/ch/qos/logback/logback-core/1.2.12/logback-core-1.2.12.jar:/Users/anish/.m2/repository/org/apache/logging/log4j/log4j-to-slf4j/2.17.2/log4j-to-slf4j-2.17.2.jar:/Users/anish/.m2/repository/org/apache/logging/log4j/log4j-api/2.17.2/log4j-api-2.17.2.jar:/Users/anish/.m2/repository/org/slf4j/jul-to-slf4j/1.7.36/jul-to-slf4j-1.7.36.jar:/Users/anish/.m2/repository/jakarta/annotation/jakarta.annotation-api/1.3.5/jakarta.annotation-api-1.3.5.jar:/Users/anish/.m2/repository/org/yaml/snakeyaml/1.30/snakeyaml-1.30.jar:/Users/anish/.m2/repository/org/springframework/data/spring-data-redis/2.7.16/spring-data-redis-2.7.16.jar:/Users/anish/.m2/repository/org/springframework/data/spring-data-keyvalue/2.7.16/spring-data-keyvalue-2.7.16.jar:/Users/anish/.m2/repository/org/springframework/data/spring-data-commons/2.7.16/spring-data-commons-2.7.16.jar:/Users/anish/.m2/repository/org/springframework/spring-tx/5.3.30/spring-tx-5.3.30.jar:/Users/anish/.m2/repository/org/springframework/spring-oxm/5.3.30/spring-oxm-5.3.30.jar:/Users/anish/.m2/repository/org/springframework/spring-aop/5.3.30/spring-aop-5.3.30.jar:/Users/anish/.m2/repository/org/springframework/spring-context-support/5.3.30/spring-context-support-5.3.30.jar:/Users/anish/.m2/repository/org/slf4j/slf4j-api/1.7.36/slf4j-api-1.7.36.jar:/Users/anish/.m2/repository/io/lettuce/lettuce-core/6.1.10.RELEASE/lettuce-core-6.1.10.RELEASE.jar:/Users/anish/.m2/repository/io/netty/netty-common/4.1.97.Final/netty-common-4.1.97.Final.jar:/Users/anish/.m2/repository/io/netty/netty-handler/4.1.97.Final/netty-handler-4.1.97.Final.jar:/Users/anish/.m2/repository/io/netty/netty-resolver/4.1.97.Final/netty-resolver-4.1.97.Final.jar:/Users/anish/.m2/repository/io/netty/netty-buffer/4.1.97.Final/netty-buffer-4.1.97.Final.jar:/Users/anish/.m2/repository/io/netty/netty-transport-native-unix-common/4.1.97.Final/netty-transport-native-unix-common-4.1.97.Final.jar:/Users/anish/.m2/repository/io/netty/netty-codec/4.1.97.Final/netty-codec-4.1.97.Final.jar:/Users/anish/.m2/repository/io/netty/netty-transport/4.1.97.Final/netty-transport-4.1.97.Final.jar:/Users/anish/.m2/repository/io/projectreactor/reactor-core/3.4.32/reactor-core-3.4.32.jar:/Users/anish/.m2/repository/org/reactivestreams/reactive-streams/1.0.4/reactive-streams-1.0.4.jar:/Users/anish/.m2/repository/org/springframework/boot/spring-boot-starter-web/2.7.16/spring-boot-starter-web-2.7.16.jar:/Users/anish/.m2/repository/org/springframework/boot/spring-boot-starter-json/2.7.16/spring-boot-starter-json-2.7.16.jar:/Users/anish/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.13.5/jackson-databind-2.13.5.jar:/Users/anish/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.13.5/jackson-annotations-2.13.5.jar:/Users/anish/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.13.5/jackson-core-2.13.5.jar:/Users/anish/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jdk8/2.13.5/jackson-datatype-jdk8-2.13.5.jar:/Users/anish/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.13.5/jackson-datatype-jsr310-2.13.5.jar:/Users/anish/.m2/repository/com/fasterxml/jackson/module/jackson-module-parameter-names/2.13.5/jackson-module-parameter-names-2.13.5.jar:/Users/anish/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/2.7.16/spring-boot-starter-tomcat-2.7.16.jar:/Users/anish/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.80/tomcat-embed-core-9.0.80.jar:/Users/anish/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/9.0.80/tomcat-embed-el-9.0.80.jar:/Users/anish/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/9.0.80/tomcat-embed-websocket-9.0.80.jar:/Users/anish/.m2/repository/org/springframework/spring-web/5.3.30/spring-web-5.3.30.jar:/Users/anish/.m2/repository/org/springframework/spring-beans/5.3.30/spring-beans-5.3.30.jar:/Users/anish/.m2/repository/org/springframework/spring-webmvc/5.3.30/spring-webmvc-5.3.30.jar:/Users/anish/.m2/repository/org/springframework/spring-context/5.3.30/spring-context-5.3.30.jar:/Users/anish/.m2/repository/org/springframework/spring-expression/5.3.30/spring-expression-5.3.30.jar:/Users/anish/.m2/repository/com/redis/om/redis-om-spring/0.6.0/redis-om-spring-0.6.0.jar:/Users/anish/.m2/repository/org/springframework/boot/spring-boot-starter-aop/2.7.16/spring-boot-starter-aop-2.7.16.jar:/Users/anish/.m2/repository/org/aspectj/aspectjweaver/1.9.7/aspectjweaver-1.9.7.jar:/Users/anish/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/2.7.16/spring-boot-autoconfigure-2.7.16.jar:/Users/anish/.m2/repository/com/redislabs/jrejson/1.5.0/jrejson-1.5.0.jar:/Users/anish/.m2/repository/redis/clients/jedis/3.8.0/jedis-3.8.0.jar:/Users/anish/.m2/repository/com/google/code/gson/gson/2.9.1/gson-2.9.1.jar:/Users/anish/.m2/repository/org/apache/commons/commons-pool2/2.11.1/commons-pool2-2.11.1.jar:/Users/anish/.m2/repository/com/redislabs/jredisearch/2.2.0/jredisearch-2.2.0.jar:/Users/anish/.m2/repository/org/json/json/20210307/json-20210307.jar:/Users/anish/.m2/repository/com/redislabs/jrebloom/2.2.0/jrebloom-2.2.0.jar:/Users/anish/.m2/repository/com/google/guava/guava/31.1-jre/guava-31.1-jre.jar:/Users/anish/.m2/repository/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar:/Users/anish/.m2/repository/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar:/Users/anish/.m2/repository/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar:/Users/anish/.m2/repository/org/checkerframework/checker-qual/3.12.0/checker-qual-3.12.0.jar:/Users/anish/.m2/repository/com/google/errorprone/error_prone_annotations/2.11.0/error_prone_annotations-2.11.0.jar:/Users/anish/.m2/repository/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar:/Users/anish/.m2/repository/com/github/f4b6a3/ulid-creator/5.0.1/ulid-creator-5.0.1.jar:/Users/anish/.m2/repository/org/apache/commons/commons-lang3/3.12.0/commons-lang3-3.12.0.jar:/Users/anish/.m2/repository/com/squareup/javapoet/1.13.0/javapoet-1.13.0.jar:/Users/anish/.m2/repository/org/springframework/boot/spring-boot-devtools/2.7.16/spring-boot-devtools-2.7.16.jar:/Users/anish/.m2/repository/org/springframework/boot/spring-boot/2.7.16/spring-boot-2.7.16.jar:/Users/anish/.m2/repository/org/springframework/boot/spring-boot-configuration-processor/2.7.16/spring-boot-configuration-processor-2.7.16.jar:/Users/anish/.m2/repository/org/projectlombok/lombok/1.18.30/lombok-1.18.30.jar:/Users/anish/.m2/repository/org/springframework/spring-core/5.3.30/spring-core-5.3.30.jar:/Users/anish/.m2/repository/org/springframework/spring-jcl/5.3.30/spring-jcl-5.3.30.jar com.example.testredis.TestRedisSpringApplication
17:26:44.447 [Thread-0] DEBUG org.springframework.boot.devtools.restart.classloader.RestartClassLoader - Created RestartClassLoader org.springframework.boot.devtools.restart.classloader.RestartClassLoader@7f476533
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.7.16)
2023-09-30 17:26:44.842 INFO 27499 --- [ restartedMain] c.e.t.TestRedisSpringApplication : Starting TestRedisSpringApplication using Java 17.0.8 on Anishs-MacBook-Pro.local with PID 27499 (/Users/anish/Downloads/test-redis-spring/target/classes started by anish in /Users/anish/Downloads/test-redis-spring)
2023-09-30 17:26:44.843 INFO 27499 --- [ restartedMain] c.e.t.TestRedisSpringApplication : No active profile set, falling back to 1 default profile: "default"
2023-09-30 17:26:44.917 INFO 27499 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2023-09-30 17:26:44.917 INFO 27499 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2023-09-30 17:26:45.425 INFO 27499 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode
2023-09-30 17:26:45.425 INFO 27499 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Redis repositories in DEFAULT mode.
2023-09-30 17:26:45.597 INFO 27499 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 159 ms. Found 1 Redis repository interfaces.
2023-09-30 17:26:46.004 INFO 27499 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'com.redis.om.spring.RedisModulesConfiguration' of type [com.redis.om.spring.RedisModulesConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2023-09-30 17:26:46.009 INFO 27499 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'customRedisConfiguration' of type [com.example.testredis.CustomRedisConfiguration$$EnhancerBySpringCGLIB$$5edc0326] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2023-09-30 17:26:46.052 INFO 27499 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'jedisConnectionFactory' of type [org.springframework.data.redis.connection.jedis.JedisConnectionFactory] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2023-09-30 17:26:46.127 INFO 27499 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'redisTemplate' of type [org.springframework.data.redis.core.RedisTemplate] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2023-09-30 17:26:46.135 INFO 27499 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'redisModulesClient' of type [com.redis.om.spring.client.RedisModulesClient] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2023-09-30 17:26:46.137 INFO 27499 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'redisModulesOperations' of type [com.redis.om.spring.ops.RedisModulesOperations] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2023-09-30 17:26:46.138 INFO 27499 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'keyspaceToIndexMap' of type [com.redis.om.spring.KeyspaceToIndexMap] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2023-09-30 17:26:46.715 INFO 27499 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2023-09-30 17:26:46.727 INFO 27499 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2023-09-30 17:26:46.728 INFO 27499 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.80]
2023-09-30 17:26:46.811 INFO 27499 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2023-09-30 17:26:46.812 INFO 27499 --- [ restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1894 ms
2023-09-30 17:26:47.040 INFO 27499 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2023-09-30 17:26:47.720 INFO 27499 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2023-09-30 17:26:47.727 INFO 27499 --- [ restartedMain] c.r.om.spring.RedisModulesConfiguration : Creating Indexes......
2023-09-30 17:26:47.735 INFO 27499 --- [ restartedMain] c.r.om.spring.RedisModulesConfiguration : Found 0 @Document annotated Beans...
2023-09-30 17:26:47.741 INFO 27499 --- [ restartedMain] c.r.om.spring.RedisModulesConfiguration : Found 1 @RedisHash annotated Beans...
2023-09-30 17:26:47.741 INFO 27499 --- [ restartedMain] c.r.om.spring.RedisModulesConfiguration : Found @RedisHash annotated class: com.example.testredis.Person
2023-09-30 17:26:47.742 INFO 27499 --- [ restartedMain] c.r.om.spring.RedisModulesConfiguration : FOUND @Indexed annotation on field of type: class java.lang.String
2023-09-30 17:26:47.743 INFO 27499 --- [ restartedMain] c.r.om.spring.RedisModulesConfiguration : FOUND @Indexed annotation on field of type: class java.lang.String
2023-09-30 17:26:47.792 INFO 27499 --- [ restartedMain] c.e.t.TestRedisSpringApplication : Started TestRedisSpringApplication in 3.335 seconds (JVM running for 3.879)
2023-09-30 19:12:53.073 INFO 27499 --- [nio-8080-exec-2] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2023-09-30 19:12:53.074 INFO 27499 --- [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2023-09-30 19:12:53.086 INFO 27499 --- [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet : Completed initialization in 11 ms
我正在使用端点在 Redis 中创建两个数据:
http://localhost:8080/person/save
截图:
Redis CLI 日志:
现在,我将尝试从 getAllById 端点获取数据:http://localhost:8080/person/find-all-by-ids
Redis CLI 日志:
仅此而已。