---
title: "Options | JavaScript maps SDK"
description: "Documentation for MapTiler SDK"
---

> For AI agents: a documentation index is available at [/llms.txt](https://docs.maptiler.com/llms.txt). Markdown versions of all pages are available by appending .md to any URL.

# Type Alias Options<KeyType, ValueType>

type Options<[KeyType](#keytype), [ValueType](#valuetype)\> \= {  
    [maxAge](#maxage)?: number;  
    [maxSize](#maxsize): number;  
    [onEviction](#oneviction)?: (key: [KeyType](#keytype), value: [ValueType](#valuetype)) \=> void;  
}

#### Type Parameters

-   KeyType
-   ValueType

##### Index

### Properties[](#properties)

[maxAge?](#maxage) [maxSize](#maxsize) [onEviction?](#oneviction)

## Properties[](#properties-1)

### `Optional` `Readonly`maxAge[](#maxage)

maxAge?: number

The maximum number of milliseconds an item should remain in the cache.

#### Default[](#default)

Infinity

By default, `maxAge` will be `Infinity`, which means that items will never expire. Lazy expiration occurs upon the next write or read call.

Individual expiration of an item can be specified with the `set(key, value, {maxAge})` method.

### `Readonly`maxSize[](#maxsize)

maxSize: number

The target maximum number of items before evicting the least recently used items.

**Note:** This package uses an [algorithm](https://github.com/sindresorhus/quick-lru#algorithm) which maintains between `maxSize` and `2 × maxSize` items for performance reasons. The cache may temporarily contain up to twice the specified size due to the dual-cache design that avoids expensive delete operations.

### `Optional`onEviction[](#oneviction)

onEviction?: (key: [KeyType](#keytype), value: [ValueType](#valuetype)) \=> void

Called right before an item is evicted from the cache due to LRU pressure, TTL expiration, or manual eviction via `evict()`.

Useful for side effects or for items like object URLs that need explicit cleanup (`revokeObjectURL`).

**Note:** This callback is not called for manual removals via `delete()` or `clear()`. It fires for automatic evictions and manual evictions via `evict()`.
