NCache 4.6 - Online Documentation

Closing a Stream

The stream should be closed after being used in any mode in order to release the lock.
       To utilize the API, include the following namespace in your application: Alachisoft.NCache.Web.Caching. 
            string key = "key:ncache-manual";
                CacheStream cacheStream = cache.GetCacheStream(key, StreamMode.Read);
                int dataSize = Convert.ToInt32(cacheStream.Length);
                byte[] dataToRead = new byte[dataSize];
                cacheStream.Read(dataToRead, 0, dataSize);
                // your logic here
            catch (StreamException e)
                // handle exception
Reading or writing a stream that was previously in use throws exception i.e. StreamAlreadyLockedExceptionif it was not closed properly.
Close the stream after all operations are done to the stream.
See Also