Add and Update Data with Streams
To utilize the API, include the following namespace in your application:
Alachisoft.NCache.Web.Caching.
The GetCacheStream
method is used for adding and updating the data within a stream. If the
key provided with GetCacheStream
API does not exist in the cache, the data
written on the stream is added to the cache.
If an item already exists in the cache with the provided key, binary data written on the stream is appended with the existing data against the specified key.
string key="key:ncache-guide";
byte[] dataToWrite = System.IO.File.ReadAllBytes("C:\\ncache-manual.pdf");
try
{
cacheStream = cache.GetCacheStream(key, StreamMode.Write);
cacheStream.Write(dataToWrite, 0, dataToWrite.Length);
//...Close stream
}
catch (StreamException ex)
{
// handle exception
}