[API reference](https://jsprismarine.dev/api/index.md) / [@jsprismarine/prismarine](https://jsprismarine.dev/api/@jsprismarine/prismarine/index.md) / [network/encodePacketBatch](https://jsprismarine.dev/api/@jsprismarine/prismarine/network/encodePacketBatch/index.md) / FullFlushFragmentCache

# Class: FullFlushFragmentCache

Defined in: [packages/prismarine/src/network/encodePacketBatch.ts:38](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/network/encodePacketBatch.ts#L38)

Reuses a compressed packet fragment without retaining its source buffer.

Tick paths use a short-lived cache. Chunk delivery may use the module cache because the
serialized payload is held by its chunk and changes identity whenever that chunk changes.

## Constructors

### Constructor

> **new FullFlushFragmentCache**(): `FullFlushFragmentCache`

#### Returns

`FullFlushFragmentCache`

## Methods

### getOrCreate()

> **getOrCreate**(`key`, `discriminator`, `packet`, `codec`, `level`): `Buffer`

Defined in: [packages/prismarine/src/network/encodePacketBatch.ts:50](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/network/encodePacketBatch.ts#L50)

Returns or synchronously creates a packet fragment.

#### Parameters

##### key

`Buffer`

Stable payload identity; weakly held so stale chunk revisions can be collected.

##### discriminator

`string`

Packet header fields not included in the stable payload key.

##### packet

`Buffer`

The complete encoded packet body.

##### codec

[`ProtocolCodec`](https://jsprismarine.dev/api/@jsprismarine/protocol/index.md#protocolcodec)

The negotiated packet layout used to encode `packet`.

##### level

`number`

The zlib level used to compress the fragment.

#### Returns

`Buffer`

The cached full-flush fragment.

***

### getOrCreateAsync()

> **getOrCreateAsync**(`key`, `discriminator`, `packet`, `codec`, `level`): `Promise`\<`Buffer`\<`ArrayBufferLike`\>\>

Defined in: [packages/prismarine/src/network/encodePacketBatch.ts:85](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/network/encodePacketBatch.ts#L85)

Returns or asynchronously creates a packet fragment, sharing in-flight work for the same key.

#### Parameters

##### key

`Buffer`

Stable payload identity; weakly held so stale chunk revisions can be collected.

##### discriminator

`string`

Packet header fields not included in the stable payload key.

##### packet

`Buffer`

The complete encoded packet body.

##### codec

[`ProtocolCodec`](https://jsprismarine.dev/api/@jsprismarine/protocol/index.md#protocolcodec)

The negotiated packet layout used to encode `packet`.

##### level

`number`

The zlib level used to compress the fragment.

#### Returns

`Promise`\<`Buffer`\<`ArrayBufferLike`\>\>

The cached or pending full-flush fragment.
