在文檔它說使用MemoryCacheHandle與RedisCacheBackplane但沒有RedisCacheHandle
/// The cache manager must have at least one cache handle configured with <see cref="CacheHandleConfiguration.IsBackplaneSource"/> set to <c>true</c>.
/// Usually this is the redis cache handle, if configured. It should be the distributed and bottom most cache handle.
我知道如何與RedisCacheHandle做到這一點,因爲它是作爲例子給出的CacheManager的網站
var cache = CacheFactory.Build<int>("myCache", settings =>
{
settings
.WithSystemRuntimeCacheHandle("inProcessCache")
.And
.WithRedisConfiguration("redis", config =>
{
config.WithAllowAdmin()
.WithDatabase(0)
.WithEndpoint("localhost", 6379);
})
.WithMaxRetries(1000)
.WithRetryTimeout(100)
.WithRedisBackplane("redis")
.WithRedisCacheHandle("redis", true);
});
的問題是我不想使用Redis作爲緩存資源;我只是想通過Redis Pub/Sub機制的力量製作分佈式緩存。根據我通過代碼進行的調試,通過使用Redis Backplane功能,我可以將消息發送到Redis並從Redis接收消息。那麼爲什麼不使用RedisCacheHandle而是使用SystemRuntimeCacheHandle呢?
所以,我的期望是用下面的緩存配置
var cache = CacheFactory.Build<int>("myCache", settings =>
{
settings
.WithSystemRuntimeCacheHandle("inProcessCache")
.And
.WithRedisConfiguration("redis", config =>
{
config.WithAllowAdmin()
.WithDatabase(0)
.WithEndpoint("localhost", 6379);
})
.WithMaxRetries(1000)
.WithRetryTimeout(100)
.WithRedisBackplane("redis")
.WithSystemRuntimeCacheHandle("inProcessCache", true);
});
的全成執行,但它不工作。你能告訴我一個解決方案嗎?我究竟做錯了什麼?或者,儘管它已經是寫在文檔中的
...通常這是Redis的緩存手柄...
是有什麼辦法可以使用緩存同步功能,而不RedisCacheHandle?
https://github.com/MichaCo/CacheManager/issues/111
我尊重您的建議,並發表我的意見,而不是github。 其實這種模式迫使我使用「高速緩存背板源」。那麼,這意味着這個來源是所有其他來源的「來源」:這意味着它是所有其他緩存句柄中的「主要來源」。這就是爲什麼Redis緩存句柄可以很好地用作背板源:因爲它是位於:地址的單個緩存。另一方面,MemoryCacheHandle不能處理這個工作。爲什麼? 這是因爲MemoryCacheHandle每次都會創建新的MemoryCache。請檢查MemoryCacheHandle類的構造函數。 –
rebulanyum
所以@michac,在另一臺計算機上考慮兩個MemoryCacheHandle。它們不能通過Redis pub/sub同步嗎?一個是主人,另一個是奴隸。那會很酷。作爲一個架構,它也應該是可能的。但它看起來像你的圖書館不支持這種方式。 – rebulanyum
現在聽起來更像是一個功能請求。讓我們把這張貼到gihtub上,並附上鍊接。我仍然不能100%確定你同步的意思是什麼?其實複製新的項目,或只是刪除已被刪除和那些?複製數據並模仿分佈式緩存是100%不是要走的路,因爲這就是爲什麼像Redis這樣的東西存在;) – MichaC