簡體   English   中英

將Cassandra與Rails應用程序一起使用

[英]Using Cassandra with rails app

我想在我的rails應用程序中使用cassandra。 我心中有幾個問題:*如何連接cassandra客戶端池? *如何在請求期間將cassandra客戶端對象存儲在所有模型對象共享的地方。 當然,如果有連接池,則需要在請求處理結束時將對象返回到該池。

非常感謝Behrang

我找到了解決方案:

我應該使用Thread.current[]以確保不會按請求重新創建cassandra客戶端。

就像是:

Thread.current[:cassandra_client] ||= Cassandra.new(keyspace, servers)

暫無
暫無

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

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