我正在尝试使用 Memcached.ClientLibrary。我能够使它正常工作,但在几次点击之后(甚至在我第一次看到页面之前),我得到了这个奇怪的错误,我在搜索它时找不到任何信息。
错误信息:
堆栈跟踪:
[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();
//要设置的代码(第二个是错误的 - 但不是在第一次点击时?!)
MemcachedClient mc = new MemcachedClient();
mc.Set(key, o, expirationTime.Value);
//获取代码
MemcachedClient mc = new MemcachedClient();
object o = mc.Get(key);
最佳答案
除了这个异常之外,我的 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 log4net 日志中还存在以下两个异常,我能够解决所有这些问题
通过确保 memcached 键不包含任何空格来排除三个异常(exception)。
引用: https://groups.google.com/forum/#!topic/memcached/4WMcTbL8ZZY
Memcached 版本: memcached-win32-1.4.4-14
关于c# - Memcached .Net 客户端 BufferedStream 错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12272134/