Retrieving Data from Streams
To read data from streams, open stream in any read mode, and simply read data from it.
Read mode can be acquired either with lock or without lock. In read with lock mode, multiple read operations can be performed simultaneously on a stream but no write operation is allowed in this mode. While in read without lock, write operations can be done parallel to read operations.
To utilize the API, include the following namespace in your application:
Alachisoft.NCache.Web.Caching.
string key = "key:ncache-guide";
try
{
CacheStream cacheStream = cache.GetCacheStream(key, StreamMode.Read);
int dataSize = Convert.ToInt32(cacheStream.Length);
byte[] dataToRead = newbyte[dataSize];
cacheStream.Read(dataToRead, 0, dataSize);
//close stream
}
catch (StreamException e)
{
//handle exception
}