# CustomCacheOptions

Defined in: [packages/cache/src/cache.ts:309](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/cache/src/cache.ts#L309)

[CacheOptions](/reference/knotkit/cache/interfaces/cacheoptions/), plus the eviction policy a `customCache` follows.

## Extends

* [`CacheOptions`](/reference/knotkit/cache/interfaces/cacheoptions/)<`K`, `V`>

## Type Parameters

### K

`K`

### V

`V`

## Properties

### capacity

> `readonly` **capacity**: `number`

Defined in: [packages/cache/src/cache.ts:56](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/cache/src/cache.ts#L56)

The bound the cache keeps itself within. Without [weigh](/reference/knotkit/cache/interfaces/cacheoptions/#weigh), it counts entries and must be a positive safe integer. With [weigh](/reference/knotkit/cache/interfaces/cacheoptions/#weigh), it bounds the exact sum of the supplied binary floating-point weights and may be any positive finite number. There is no rounding tolerance at the bound.

#### Inherited from

[`CacheOptions`](/reference/knotkit/cache/interfaces/cacheoptions/).[`capacity`](/reference/knotkit/cache/interfaces/cacheoptions/#capacity)

***

### weigh?

> `readonly` `optional` **weigh?**: (`key`, `value`) => `number`

Defined in: [packages/cache/src/cache.ts:62](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/cache/src/cache.ts#L62)

Give one entry’s share of [capacity](/reference/knotkit/cache/interfaces/cacheoptions/#capacity). Called once per `set`, before the cache changes. The result must be a positive finite number no larger than `capacity`. Omit it to weigh every entry as 1.

#### Parameters

##### key

`K`

##### value

`V`

#### Returns

`number`

#### Inherited from

[`CacheOptions`](/reference/knotkit/cache/interfaces/cacheoptions/).[`weigh`](/reference/knotkit/cache/interfaces/cacheoptions/#weigh)

***

### timeToLive?

> `readonly` `optional` **timeToLive?**: `number`

Defined in: [packages/cache/src/cache.ts:68](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/cache/src/cache.ts#L68)

How long after its `set` an entry stays readable, in the milliseconds of [clock](/reference/knotkit/cache/interfaces/cacheoptions/#clock). An entry whose age has reached `timeToLive` is never returned again. Requires `clock`.

#### Inherited from

[`CacheOptions`](/reference/knotkit/cache/interfaces/cacheoptions/).[`timeToLive`](/reference/knotkit/cache/interfaces/cacheoptions/#timetolive)

***

### clock?

> `readonly` `optional` **clock?**: [`Clock`](/reference/knotkit/cache/type-aliases/clock/)

Defined in: [packages/cache/src/cache.ts:73](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/cache/src/cache.ts#L73)

The time source that [timeToLive](/reference/knotkit/cache/interfaces/cacheoptions/#timetolive) is measured against. A clock that moves backwards only delays expiry.

#### Inherited from

[`CacheOptions`](/reference/knotkit/cache/interfaces/cacheoptions/).[`clock`](/reference/knotkit/cache/interfaces/cacheoptions/#clock)

***

### trace?

> `readonly` `optional` **trace?**: `object`

Defined in: [packages/cache/src/cache.ts:80](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/cache/src/cache.ts#L80)

Receive a [CacheTraceEvent](/reference/knotkit/cache/interfaces/cachetraceevent/) for each hit, miss, insert, update, eviction, delete, and expiry, in order, so a caller can replay or scrub the policy’s behavior. Any array fits. Omitted, the cache allocates no event objects. Events are immutable; the sink is not read by the cache.

#### push

> `readonly` **push**: (`event`) => `unknown`

##### Parameters

###### event

[`CacheTraceEvent`](/reference/knotkit/cache/interfaces/cachetraceevent/)<`K`>

##### Returns

`unknown`

#### Inherited from

[`CacheOptions`](/reference/knotkit/cache/interfaces/cacheoptions/).[`trace`](/reference/knotkit/cache/interfaces/cacheoptions/#trace)

***

### policy

> `readonly` **policy**: [`CacheEvictionPolicyFactory`](/reference/knotkit/cache/type-aliases/cacheevictionpolicyfactory/)<`K`>

Defined in: [packages/cache/src/cache.ts:311](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/cache/src/cache.ts#L311)

Build the cache’s eviction policy.
