簡體   English   中英

Spring 數據 redis(帶生菜)創建包裝庫的優勢

[英]Spring data redis (with lettuce) advantages for creating wrapper library

我是 Redis 的新手,並計划在 memory 緩存中使用它。 我正在使用 Lettuce 5.2 客戶端。

我有多個應用程序將在 memory 緩存中使用 redis。 我的想法是使用像包裝器一樣的生菜編寫庫,它可以被多個應用程序使用,以便與 Redis 進行交互。 該庫將管理連接池、redis 故障轉移案例和命令執行等,因此應用程序編寫者不必擔心所有這些,只需使用我的庫即可。

現在對於這個庫,我對以下幾點感到困惑:

1)我應該使用 Spring 數據 redis(它也支持生菜)嗎? 如果我的目標是創建庫,那么首先,我可以使用 spring 數據 redis 嗎?

2) Spring 數據 redis 會給我帶來什么優勢。 我檢查了文檔https://docs.spring.io/spring-data/data-redis/docs/current/reference/html/#reference

3) 如果我不使用 Spring 數據 redis 那么我將只使用生菜並自己創建客戶端、連接池等。

我很困惑是否應該使用 spring 數據 redis 來創建庫?

你能幫我消除我的困惑嗎?

您可以在 Spring 數據中實現自定義Repository方法,這已在 SO 的其他答案中進行了概述,例如此處: 如何將自定義方法添加到 Spring 數據 JPA中。

So you can easily combine both the out of the box Spring Data Redis functionality with custom Lettuce method code for a Spring Data Repository, I would suggest starting with Spring Data, and if you need to fine tune anything beyond that then write a custom methods with生菜。

只要您可以在 Lettuce 中使用與 Spring 數據 Redis 相同的連接池,您就應該能夠將其作為資源共享,就像您可以將線程視為資源一樣。

關於應該或不應該使用哪些庫,沒有人能真正給你一個肯定的答案,希望你現在有足夠的信息來取得進展。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM