2012-09-04 120 views
3

我是嘗試以使用Memcached.ClientLibrary。我能夠使它工作,除了一些點擊之後(甚至在我第一次看到頁面之前),我都會得到這個奇怪的錯誤,在搜索它時我找不到任何信息。Memcached .Net客戶端BufferedStream錯誤

錯誤消息:如果底層流是不可搜索讀緩衝器不爲空

無法寫入一個BufferedStream。確保此BufferedStream下的流可以在此BufferedStream上尋找或避免交織讀取和寫入操作。

堆棧跟蹤:

[NotSupportedException: Cannot write to a BufferedStream while the read buffer is not empty if the underlying stream is not seekable. Ensure that the stream underlying this BufferedStream can seek or avoid interleaving read and write operations on this BufferedStream.] 
System.IO.BufferedStream.ClearReadBufferBeforeWrite() +10447571 
System.IO.BufferedStream.Write(Byte[] array, Int32 offset, Int32 count) +163 
Memcached.ClientLibrary.SockIO.Write(Byte[] bytes, Int32 offset, Int32 count) in C:\devroot\memcacheddotnet\trunk\clientlib\src\clientlib\SockIO.cs:411 
Memcached.ClientLibrary.SockIO.Write(Byte[] bytes) in C:\devroot\memcacheddotnet\trunk\clientlib\src\clientlib\SockIO.cs:391 
Memcached.ClientLibrary.MemcachedClient.Set(String cmdname, String key, Object obj, DateTime expiry, Object hashCode, Boolean asString) in C:\devroot\memcacheddotnet\trunk\clientlib\src\clientlib\MemCachedClient.cs:766 
Memcached.ClientLibrary.MemcachedClient.Set(String key, Object value, DateTime expiry) in C:\devroot\memcacheddotnet\trunk\clientlib\src\clientlib\MemCachedClient.cs:465 
Yuusoft.Julian.Server.Models.Utils.Caching.CacheWrapper.Add(CacheKey key, T o, CacheDependency dependencies, Nullable`1 expirationTime, CacheItemRemovedCallback callBack) 

我的代碼初始化(靜態構造函數):

 SockIOPool pool = SockIOPool.GetInstance(); 
     pool.SetServers(CacheWrapper.Servers); 

     pool.InitConnections = 3; 
     pool.MinConnections = 1; 
     pool.MaxConnections = 50; 

     pool.SocketConnectTimeout = 1000; 
     pool.SocketTimeout = 3000; 

     pool.MaintenanceSleep = 30; 
     pool.Failover = true; 

     pool.Nagle = false; 
     pool.Initialize(); 

//代碼來設置(第二個是一個erroing - 但不是在第一點擊?!)

 MemcachedClient mc = new MemcachedClient(); 
     mc.Set(key, o, expirationTime.Value); 

//代碼得到

 MemcachedClient mc = new MemcachedClient(); 
     object o = mc.Get(key); 
+0

ü可以發佈您的代碼? – DarthVader

+0

@DarthVader,發佈我的代碼。你有什麼想法?有什麼東西可以讓我指出正確的方向? –

+0

@FabioMilheiro如果這個問題得到解決,請發佈您的解決方案 –

回答

1

除了這種例外,以下兩種情況例外也存在於我的memcached log4net的日誌Memcached.ClientLibrary的(Error storing data in cache for key:<key with spaces>Exception thrown while trying to get object from cache for key:<key with spaces>),我是能夠通過確保memcached的關鍵,解決所有這些 三個例外不包含任何空格。

參考:https://groups.google.com/forum/#!topic/memcached/4WMcTbL8ZZY

Memcached的版本: memcached的-win32-1.4.4-14