我是新手Redis并使用Spring Boot + Spring Data Redis示例。在这个例子中,我使用了QueryByExampleRedisExecutor<T>on repository 方法并使用ExampleAPI 来执行自定义查询。
以下是 Redis NoSQL DB 中存在的 KEYS。
redis 127.0.0.1:6379> KEYS *
1) "country:76c78bcc-bb2a-41b3-a1fc-3dbb3042edd6:idx"
2) "country:76c78bcc-bb2a-41b3-a1fc-3dbb3042edd6"
3) "user:lastName:Kerr"
4) "user"
5) "user:role.roleName:API"
6) "country:countryName:India"
7) "Student:name:John Doe"
8) "user:8252a4b3-22a1-4e6c-99fc-04fed93a21a5:idx"
9) "user:8252a4b3-22a1-4e6c-99fc-04fed93a21a5"
10) "user:middleName:Lima"
11) "Student"
12) "user:middleName:Mike"
13) "user:firstName:John"
14) "country:countryCode:+91"
15) "user:role.roleName:ADMIN"
16) "user:lastName:Wixson"
17) "Student:1:idx"
18) "user:46ca0606-38a5-4d0c-8cea-38e2c4fa5bfa:idx"
19) "Student:2:idx"
20) "Student:1"
21) "user:firstName:Matt"
22) "user:46ca0606-38a5-4d0c-8cea-38e2c4fa5bfa"
23) "Student:2"
24) "country"
25) "Student:name:Michael Harford"
26) "country:84fc82f2-1c21-4d3e-9429-f1ee1039ceed:idx"
27) "country:84fc82f2-1c21-4d3e-9429-f1ee1039ceed"
redis 127.0.0.1:6379>
存储库方法 -
Example<User> example = Example.of(User.builder().firstName("Mike").build());
long count = userRepository.count();
System.out.println(count);
当我执行下面的方法时,我期望只得到一个结果,但我得到了两个结果。为什么 ?
此处显示的更多信息:考虑重新访问上面的条目或在您的配置中定义类型为“org.springframework.data.redis.core.RedisTemplate”的 bean
我们怎么能看到Redis snippet日志上的?我需要设置什么配置?
public interface UserRepository extends CrudRepository<User, String>, QueryByExampleExecutor<User>{
List<User> findByFirstName(String firstName);
List<User> findByFirstNameAndLastName(String firstName, String lastName);
@Query("SELECT u FROM User u WHERE u.middleName LIKE :middleName ")
List<User> findCustomByMiddleName(@Param("middleName") String middleName);
List<User> findByRole_RoleName(String roleName);
}
噜噜哒
犯罪嫌疑人X
相关分类