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

Interface IDistributedQueue<T>

This interface contains methods and parameters for Distributed Queue.

Inherited Members
IDistributedDataTypes.Key
IDistributedDataTypes.WriteThruOptions
ILockable.Lock(TimeSpan)
ILockable.Unlock()
INotifiable.RegisterNotification(DataTypeDataNotificationCallback, EventType, DataTypeEventDataFilter)
INotifiable.UnRegisterNotification(DataTypeDataNotificationCallback, EventType)
Assembly: Alachisoft.NCache.Client.dll
Syntax
public interface IDistributedQueue<T> : IEnumerable<T>, ICollection, IEnumerable, IDistributedDataTypes, ILockable, INotifiable
Type Parameters
Name Description
T

The type of elements in the Queue.

Methods

Clear()

Removes all objects from the IQueue.

Declaration
void Clear()
Examples

The following code sample shows how to clear Distributed Queue.

ICache cache = CacheManager.GetCache("demoClusteredCache");
string dataTypeName = "DistributedQueue";

IDistributedQueue<Product> queue = cache.DataTypeManager.GetQueue<Product>(dataTypeName);
queue.Clear();

Contains(T)

Determines whether the element exists in IQueue.

Declaration
bool Contains(T item)
Parameters
Type Name Description
T item

The object to locate.

Returns
Type Description
System.Boolean

True, if found in the IQueue otherwise; false.

Examples

The following code sample shows how to check whether the element exists in Distributed Queue.

ICache cache = CacheManager.GetCache("demoClusteredCache");
string dataTypeName = "DistributedQueue";

IDistributedQueue<Product> queue = cache.DataTypeManager.GetQueue<Product>(dataTypeName);

Product product = new Product();
product.Id = 1;
product.Name = "Chai";

bool result = queue.Contains(product);

CopyTo(T[], Int32)

Copies the IQueue elements to the specified array, starting at the specified index.

Declaration
void CopyTo(T[] array, int arrayIndex)
Parameters
Type Name Description
T[] array

The destination array of the elements copied from IQueue.

System.Int32 arrayIndex

The zero-based index in array at which copying begins.

Examples

The following code sample shows how to copy the entire source Queue to the target Array starting at 0th index.

ICache cache = CacheManager.GetCache("demoClusteredCache");
string dataTypeName = "DistributedQueue";

IDistributedQueue<Product> queue = cache.DataTypeManager.GetQueue<Product>(dataTypeName);

Product[] products = new Product[queue.Count];

queue.CopyTo(products, 0);

Dequeue()

Removes and returns the object at the beginning of the IQueue.

Declaration
T Dequeue()
Returns
Type Description
T

The object that is removed from the beginning of the IQueue.

Examples

The following code sample shows how to dequeue an object from Distributed Queue.

ICache cache = CacheManager.GetCache("demoClusteredCache");
string dataTypeName = "DistributedQueue";

IDistributedQueue<Product> queue = cache.DataTypeManager.GetQueue<Product>(dataTypeName);

Product product = queue.Dequeue();

DequeueBulk(Int32)

Removes and returns a list of objects at the beginning of the IQueue.

Declaration
IList<T> DequeueBulk(int maxitems = 10)
Parameters
Type Name Description
System.Int32 maxitems

The maximum number of items to remove from the IQueue.

Returns
Type Description
System.Collections.Generic.IList<T>

The list of objects that are removed from the beginning of the IQueue.

Examples

The following code sample shows how to dequeue a list of objects from Distributed Queue.

ICache cache = CacheManager.GetCache("demoClusteredCache");
string dataTypeName = "DistributedQueue";

IDistributedQueue<Product> queue = cache.DataTypeManager.GetQueue<Product>(dataTypeName);

IList<Product> product = queue.DequeueBulk();

Enqueue(T)

Adds an object to the end of the IQueue.

Declaration
void Enqueue(T item)
Parameters
Type Name Description
T item

The object to add to the IQueue.

Examples

The following code sample shows how to to enqueue an object in Distributed Queue.

ICache cache = CacheManager.GetCache("demoClusteredCache");
string dataTypeName = "DistributedQueue";

IDistributedQueue<Product> queue = cache.DataTypeManager.GetQueue<Product>(dataTypeName);

Product product = new Product();
product.Id = 1;
product.Name = "Chai";

queue.Enqueue(product);

EnqueueBulk(IList<T>)

Adds a list of objects to the end of the IQueue.

Declaration
void EnqueueBulk(IList<T> items)
Parameters
Type Name Description
System.Collections.Generic.IList<T> items

The list of objects to add to the IQueue.

Examples

The following code sample shows how to to enqueue a list of objects in a Distributed Queue.

ICache cache = CacheManager.GetCache("demoClusteredCache");
string dataTypeName = "DistributedQueue";

IDistributedQueue<Product> queue = cache.DataTypeManager.GetQueue<Product>(dataTypeName);

Product product = new Product();
product.Id = 1;
product.Name = "Chai";

IList<Product> products = new List<Product> { product }

queue.EnqueueBulk(products);

Peek()

Returns the object at the beginning of the IQueue without removing it.

Declaration
T Peek()
Returns
Type Description
T

The object at the beginning of the IQueue

Examples

The following code sample shows how to get an object from the beginning of the distributed queue without removing it.

ICache cache = CacheManager.GetCache("demoClusteredCache");
string dataTypeName = "DistributedQueue";

IDistributedQueue<Product> queue = cache.DataTypeManager.GetQueue<Product>(dataTypeName);

Product product = queue.Peek();

ToArray()

Copies the IQueue elements to a new array.

Declaration
T[] ToArray()
Returns
Type Description
T[]

A new array containing elements copied from the IQueue.

Examples

The following code sample shows how to copy a Queue into a one-dimensional array.

ICache cache = CacheManager.GetCache("demoClusteredCache");
string dataTypeName = "DistributedQueue";

IDistributedQueue<Product> queue = cache.DataTypeManager.GetQueue<Product>(dataTypeName);

Product[] products = queue.ToArray();

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