ERR only (P)SUBSCRIBE / (P)UNSUBSCRIBE / PING / QUIT allowed in this context

封裝Redis發佈訂閱時,SUB時,又想探測具體Channel的狀態,因而執行PUBSUB CHNNALES命令,報
ERR only (P)SUBSCRIBE / (P)UNSUBSCRIBE / PING / QUIT allowed in this context 的錯誤。
緣由:
發佈訂閱模式下不能共用一個TCP鏈接,也不能在其上面執行其餘命令 only (P)SUBSCRIBE / (P)UNSUBSCRIBE / PING / QUIT allowed。this

解決方法
一、修改Redis底層源碼
二、重開一個鏈接,進行其餘操做,加個Redis鏈接池。源碼

相關文章
相關標籤/搜索