# GeneratorPooledCache Methods

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.providers.streams.generator.generatorpooledcache/)

## AddToCache(IList&lt;IBatchContainer&gt;) {#addtocache-system-collections-generic-ilist-orleans-streams-ibatchcontainer-94ffcddc}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.providers.streams.generator.generatorpooledcache/methods/addtocache-system-collections-generic-ilist-orleans-streams-ibatchcontainer-94ffcddc/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Streaming/Generator/GeneratorPooledCache.cs#L160-L166)

```csharp
public void AddToCache(IList<IBatchContainer> messages)
```

Adds messages to the cache.

### Parameters

- `messages` (`IList<IBatchContainer>`): The message batches.

## GetBatchContainer(CachedMessage) {#getbatchcontainer-ref-orleans-providers-streams-common-cachedmessage-fa3dbbbf}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.providers.streams.generator.generatorpooledcache/methods/getbatchcontainer-ref-orleans-providers-streams-common-cachedmessage-fa3dbbbf/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Streaming/Generator/GeneratorPooledCache.cs#L46-L50)

```csharp
public IBatchContainer GetBatchContainer(ref CachedMessage cachedMessage)
```

Converts a cached message to a batch container for delivery

### Parameters

- `cachedMessage` (`CachedMessage`): The cached message.

### Returns

The batch container.

## GetCacheCursor(StreamId, StreamSequenceToken) {#getcachecursor-orleans-runtime-streamid-orleans-streams-streamsequencetoken-24693218}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.providers.streams.generator.generatorpooledcache/methods/getcachecursor-orleans-runtime-streamid-orleans-streams-streamsequencetoken-24693218/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Streaming/Generator/GeneratorPooledCache.cs#L179)

```csharp
public IQueueCacheCursor GetCacheCursor(StreamId streamId, StreamSequenceToken token)
```

Acquire a stream message cursor. This can be used to retrieve messages from the cache starting at the location indicated by the provided token.

### Parameters

- `streamId` (`StreamId`): The stream identifier.
- `token` (`StreamSequenceToken`): The token.

### Returns

The queue cache cursor.

## GetMaxAddCount {#getmaxaddcount-23e3f638}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.providers.streams.generator.generatorpooledcache/methods/getmaxaddcount-23e3f638/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Streaming/Generator/GeneratorPooledCache.cs#L155)

```csharp
public int GetMaxAddCount()
```

Gets the maximum number of items that can be added.

### Returns

The maximum number of items that can be added.

## GetSequenceToken(CachedMessage) {#getsequencetoken-ref-orleans-providers-streams-common-cachedmessage-49d26d32}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.providers.streams.generator.generatorpooledcache/methods/getsequencetoken-ref-orleans-providers-streams-common-cachedmessage-49d26d32/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Streaming/Generator/GeneratorPooledCache.cs#L56)

```csharp
public StreamSequenceToken GetSequenceToken(ref CachedMessage cachedMessage)
```

Gets the stream sequence token from a cached message.

### Parameters

- `cachedMessage` (`CachedMessage`): The cached message.

### Returns

The sequence token.

## IsUnderPressure {#isunderpressure-c2bc8e60}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.providers.streams.generator.generatorpooledcache/methods/isunderpressure-c2bc8e60/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Streaming/Generator/GeneratorPooledCache.cs#L185)

```csharp
public bool IsUnderPressure()
```

Returns `true` if this cache is under pressure, `false` otherwise.

### Returns

`true` if this cache is under pressure; otherwise, `false`.

## TryPurgeFromCache(IList&lt;IBatchContainer&gt;) {#trypurgefromcache-out-system-collections-generic-ilist-orleans-streams-ibatchcon-0bf42e33}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.providers.streams.generator.generatorpooledcache/methods/trypurgefromcache-out-system-collections-generic-ilist-orleans-streams-ibatchcon-0bf42e33/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Streaming/Generator/GeneratorPooledCache.cs#L171-L173)

```csharp
public bool TryPurgeFromCache(out IList<IBatchContainer> purgedItems)
```

Requests that the cache purge any items that can be purged.

### Parameters

- `purgedItems` (`IList<IBatchContainer>`): The purged items.

### Returns

`true` if items were successfully purged from the cache., `false` otherwise.
