# MemoryPooledCache&lt;TSerializer&gt; Methods

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.providers.memorypooledcache-1/)

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

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.providers.memorypooledcache-1/methods/addtocache-system-collections-generic-ilist-orleans-streams-ibatchcontainer-49daceb4/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Streaming/MemoryStreams/MemoryPooledCache.cs#L154-L161)

```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-9fdf5f57}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.providers.memorypooledcache-1/methods/getbatchcontainer-ref-orleans-providers-streams-common-cachedmessage-9fdf5f57/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Streaming/MemoryStreams/MemoryPooledCache.cs#L187-L191)

```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-82d192d0}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.providers.memorypooledcache-1/methods/getcachecursor-orleans-runtime-streamid-orleans-streams-streamsequencetoken-82d192d0/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Streaming/MemoryStreams/MemoryPooledCache.cs#L174)

```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-570750ec}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.providers.memorypooledcache-1/methods/getmaxaddcount-570750ec/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Streaming/MemoryStreams/MemoryPooledCache.cs#L148)

```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-a781b66a}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.providers.memorypooledcache-1/methods/getsequencetoken-ref-orleans-providers-streams-common-cachedmessage-a781b66a/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Streaming/MemoryStreams/MemoryPooledCache.cs#L197)

```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-b4467418}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.providers.memorypooledcache-1/methods/isunderpressure-b4467418/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Streaming/MemoryStreams/MemoryPooledCache.cs#L180)

```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-e1e20b4b}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.providers.memorypooledcache-1/methods/trypurgefromcache-out-system-collections-generic-ilist-orleans-streams-ibatchcon-e1e20b4b/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Streaming/MemoryStreams/MemoryPooledCache.cs#L166-L168)

```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.
