• Facebook
  • Twitter
  • Youtube
  • LinedIn
  • RSS
  • Docs
  • Comparisons
  • Blogs
  • Download
  • Contact Us
Download
Show / Hide Table of Contents

Class CacheStream

CacheStream is derived from System.IO.Stream. It is designed to serve/fetch BLOB (Binary Large Object) using the standard stream interface.

Inheritance
System.Object
System.MarshalByRefObject
System.IO.Stream
CacheStream
Assembly: Alachisoft.NCache.Client.dll
Syntax
public class CacheStream : Stream, IDisposable

Properties

CanRead

Gets a value indicating whether the current stream supports reading.

Declaration
public override bool CanRead { get; }
Property Value
Type Description
System.Boolean

It specifies a boolean value, either true or false.

Overrides
System.IO.Stream.CanRead
Remarks

Returns true, if stream is opened with either StreamMode.Read or StreamMode.ReadWithoutLock.

CanSeek

Gets a value indicating whether the current stream supports seeking.

Declaration
public override bool CanSeek { get; }
Property Value
Type Description
System.Boolean

It specifies a boolean value, either true or false.

Overrides
System.IO.Stream.CanSeek
Remarks

Always returns false, because CacheStream does not support seek operation.

CanWrite

Gets a value indicating whether the current stream supports writing.

Declaration
public override bool CanWrite { get; }
Property Value
Type Description
System.Boolean

It specifies a boolean value, either true or false.

Overrides
System.IO.Stream.CanWrite
Remarks

Returns true, if stream is opened with StreamMode.Write.

Length

Gets the length of the stream.

Declaration
public override long Length { get; }
Property Value
Type Description
System.Int64

This property specifies the length of the stream.

Overrides
System.IO.Stream.Length
Exceptions
Type Condition
System.ObjectDisposedException

Stream is closed.

StreamAlreadyLockedException

Stream is already locked.

StreamInvalidLockException

Lock acquired by current stream has become invalid.

StreamNotFoundException

Stream is not found in the cache.

Position

Gets/Sets the position within current stream.

Declaration
public override long Position { get; set; }
Property Value
Type Description
System.Int64

Gets/Sets the position within current stream.

Overrides
System.IO.Stream.Position
Exceptions
Type Condition
System.NotSupportedException

Stream does not support seeking.

Methods

Close()

Closes the current stream and releases any resources associated with the current stream.

Declaration
public override void Close()
Overrides
System.IO.Stream.Close()
Remarks

A call to close is required if stream is opened with StreamMode.Read or StreamMode.Write to release locks.

Exceptions
Type Condition
StreamAlreadyLockedException

Stream is already locked.

StreamInvalidLockException

Lock acquired by current stream has become invalid.

StreamNotFoundException

Stream is not found in the cache.

Flush()

When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device.

Declaration
public override void Flush()
Overrides
System.IO.Stream.Flush()
Remarks

CacheStream does not buffer the data. Each read/write operations is performed on the cache.

GetBufferedStream()

Gets System.IO.BufferedStream of given buffer size.

Declaration
public Stream GetBufferedStream()
Returns
Type Description
System.IO.Stream

An instance of System.IO.BufferedStream with buffer size of 4 Kb.

Remarks

CacheStream does not buffer the data. Each read/write operation performed on the stream is propagated to cache. However, this can cause performance issues if small chunks of data are being read/written from/to stream. System.IO.BufferedStream supports buffering of data. This method returns an instance of System.IO.BufferedStream which encapsulates CacheStream.

GetBufferedStream(Int32)

Gets System.IO.BufferedStream of given buffer size.

Declaration
public Stream GetBufferedStream(int bufferSize)
Parameters
Type Name Description
System.Int32 bufferSize

Buffer size in bytes.

Returns
Type Description
System.IO.Stream

An instance of System.IO.BufferedStream.

Remarks

CacheStream does not buffer the data. Each read/write operation performed on the stream is propagated to cache. However, this can cause performance issues if small chunks of data are being read/written from/to stream. System.IO.BufferedStream supports buffering of data. This method returns an instance of System.IO.BufferedStream which encapsulates CacheStream.

Read(Byte[], Int32, Int32)

Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.

Declaration
public override int Read(byte[] buffer, int offset, int count)
Parameters
Type Name Description
System.Byte[] buffer

An array of bytes. When this method returns, the buffer contains the specified byte array with the values between offset and (offset + count - 1) replaced by the bytes read from the current source.

System.Int32 offset

The zero-based byte offset in buffer that determines when to begin storing the data being read from the current stream.

System.Int32 count

The maximum number of bytes to be read from the current stream.

Returns
Type Description
System.Int32

The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero (0) if the end of the stream has been reached.

Overrides
System.IO.Stream.Read(System.Byte[], System.Int32, System.Int32)
Remarks

This method is not thread-safe.

Exceptions
Type Condition
StreamAlreadyLockedException

Stream is already locked.

StreamInvalidLockException

Lock acquired by current stream has become invalid.

StreamNotFoundException

Stream is not found in the cache.

Seek(Int64, SeekOrigin)

Sets the position within the current stream.

Declaration
public override long Seek(long offset, SeekOrigin origin)
Parameters
Type Name Description
System.Int64 offset

A byte offset relative to the origin parameter.

System.IO.SeekOrigin origin

A value of type SeekOrigin indicating the reference point used to obtain the new position.

Returns
Type Description
System.Int64

Position of the byte(s) within the current stream.

Overrides
System.IO.Stream.Seek(System.Int64, System.IO.SeekOrigin)
Remarks

CacheStream does not support seeking.

Exceptions
Type Condition
System.NotSupportedException

Stream does not support seeking.

SetLength(Int64)

Sets the length of the stream.

Declaration
public override void SetLength(long value)
Parameters
Type Name Description
System.Int64 value

The desired length of the current stream in bytes.

Overrides
System.IO.Stream.SetLength(System.Int64)
Exceptions
Type Condition
System.NotSupportedException

Stream does not support both writing and seeking.

Write(Byte[], Int32, Int32)

Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

Declaration
public override void Write(byte[] buffer, int offset, int count)
Parameters
Type Name Description
System.Byte[] buffer

An array of bytes. This method copies count bytes from buffer to the current stream.

System.Int32 offset

The zero-based byte offset in buffer that determine when to begin copying bytes to the current stream.

System.Int32 count

The number of bytes to be written to the current stream.

Overrides
System.IO.Stream.Write(System.Byte[], System.Int32, System.Int32)
Remarks

This method is not thread-safe.

Exceptions
Type Condition
StreamAlreadyLockedException

Stream is already locked.

StreamInvalidLockException

Lock acquired by current stream has become invalid.

StreamNotFoundException

Stream is not found in the cache.

Contact Us

PHONE

+1 (214) 764-6933   (US)

+44 20 7993 8327   (UK)

 
EMAIL

sales@alachisoft.com

support@alachisoft.com

NCache
  • NCache Enterprise
  • NCache Community
  • Edition Comparison
  • NCache Architecture
  • Benchmarks
Download
Pricing
Try Playground

Deployments
  • Cloud (SaaS & Software)
  • On-Premises
  • Kubernetes
  • Docker
Technical Use Cases
  • ASP.NET Sessions
  • ASP.NET Core Sessions
  • Pub/Sub Messaging
  • Real-Time ASP.NET SignalR
  • Internet of Things (IoT)
  • NoSQL Database
  • Stream Processing
  • Microservices
Resources
  • Magazine Articles
  • Third-Party Articles
  • Articles
  • Videos
  • Whitepapers
  • Shows
  • Talks
  • Blogs
  • Docs
Customer Case Studies
  • Testimonials
  • Customers
Support
  • Schedule a Demo
  • Forum (Google Groups)
  • Tips
Company
  • Leadership
  • Partners
  • News
  • Events
  • Careers
Contact Us

  • EnglishChinese (Simplified)FrenchGermanItalianJapaneseKoreanPortugueseSpanish

  • Contact Us
  •  
  • Sitemap
  •  
  • Terms of Use
  •  
  • Privacy Policy
© Copyright Alachisoft 2002 - . All rights reserved. NCache is a registered trademark of Diyatech Corp.
Back to top