# ArtifactBackend

Defined in: [packages/cas/src/artifact.ts:37](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/cas/src/artifact.ts#L37)

The storage a [ContentAddressedStore](/reference/knotkit/cas/interfaces/contentaddressedstore/) writes through.

Injected rather than bundled, because the tree ships no runtime that reads files: an in-memory `Map`, an S3 client, a `fetch`-backed object store, and a browser cache all satisfy this shape. The backend owns durability, listing, and concurrency; the store owns framing, addressing, and verification.

A backend that returns the wrong bytes for a key is not trusted: `get` re-hashes what it reads and refuses to decode a mismatch.

The members are `get` and `set`, the vocabulary’s settled spellings for a keyed store’s read and write. `read` and `write` are reserved for a fixed-width field primitive.

## Properties

### has

> `readonly` **has**: (`address`) => `Promise`<`boolean`>

Defined in: [packages/cas/src/artifact.ts:39](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/cas/src/artifact.ts#L39)

Whether `address` is present. O(1) expected for a map-backed backend.

#### Parameters

##### address

`string`

#### Returns

`Promise`<`boolean`>

***

### set

> `readonly` **set**: (`address`, `bytes`) => `Promise`<`void`>

Defined in: [packages/cas/src/artifact.ts:48](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/cas/src/artifact.ts#L48)

Store `bytes` under `address`, replacing whatever was there.

Content addressing makes a rewrite idempotent when the hash is deterministic, so a backend need not be idempotent itself: the store writes an address only when it read nothing back, or read back different bytes that it has already reported as a failure.

#### Parameters

##### address

`string`

##### bytes

`Uint8Array`

#### Returns

`Promise`<`void`>

***

### get

> `readonly` **get**: (`address`) => `Promise`<`Uint8Array`<`ArrayBufferLike`> | `undefined`>

Defined in: [packages/cas/src/artifact.ts:50](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/cas/src/artifact.ts#L50)

Return the bytes stored under `address`, or `undefined` when the address is absent.

#### Parameters

##### address

`string`

#### Returns

`Promise`<`Uint8Array`<`ArrayBufferLike`> | `undefined`>
