如何在以mysql和pgsql为数据源的Spring boot data jpa项目中使用aerospike作为缓存?

问题描述 投票:0回答:1

我们已经在 spring boot + spring data jpa + mysql&pgsql 作为数据库中实现了我们的应用程序。我们可以仅使用 aerospike 作为我的应用程序的缓存吗?没有合适的文档或示例项目可供参考。

java spring-boot spring-data-jpa aerospike
1个回答
0
投票

有 2 个选项可以使用 Aerospike 作为 Spring Boot 的缓存层:

  1. 将 Spring Data Aerospike 与 Aerospike 支持的 Spring Cache 功能结合使用,这样您就不需要编写缓存实现逻辑,或者您可以使用 @Cacheable、CachePut 和 @CacheEvict 等注释来负责实际实现在幕后,这里有一篇关于它的博客文章:https://medium.com/aerospike-developer-blog/caching-with-spring-boot-and-aerospike-17b91267d6c

  2. 使用 Spring Data Aerospike 编写自己的缓存实现逻辑(尝试在 Aerospike 中搜索一条记录,如果没有找到则转到 MySQL/PostgreSQL,写回到 Aerospike 等...),可以使用 AerospikeRepository 减少很多样板代码它不会像使用第一个选项那么容易,但会更灵活。

我建议访问 Spring Data Aerospike GitHub 存储库,浏览 README 和文档,可能还有适合您要求的博客文章/示例:https://github.com/aerospike/spring-data-aerospike

© www.soinside.com 2019 - 2024. All rights reserved.