简体   繁体   English

你将如何在 R2DBC 中缓存?

[英]How would you cache in R2DBC?

I am trying to implement something like this Spring boot populating cache used by findById method with findAll method我正在尝试用 findAll 方法实现 findById 方法使用的 Spring 引导填充缓存之类的东西

but with R2DBC.但使用 R2DBC。 However, it does not appear to work as I am returning a Mono.但是,它似乎不起作用,因为我要返回 Mono。

@Cacheable("stores",key = "#storeId")
Mono<Store> findById(int storeId);

The way I determine it is looking at the general_log of the database and find that it's still performing the query我确定它的方式是查看数据库的general_log,发现它仍在执行查询

I'm not familiar with there being any fluent integration between the @Cacheable annotation and reactive frameworks.我不熟悉 @Cacheable 注释和反应框架之间的任何流畅集成。 The primary issue is that there are no non-blocking cache implementations (JSR-107 cache API is blocking).主要问题是没有非阻塞缓存实现(JSR-107 缓存 API 是阻塞的)。 Only Redis is providing a reactive driver.只有 Redis 提供反应式驱动程序。 See Spring.io's reactive caching guide .请参阅 Spring.io 的反应式缓存指南 I've read somewhere that you can still use the annotation on service methods, but that will "only" cache your wrapper objects, ie, Mono / Flux, but not the actual result of your findById..我在某处读到您仍然可以在服务方法上使用注释,但这将“仅”缓存您的包装器对象,即 Mono / Flux,但不是您的 findById 的实际结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM