[API reference](https://evolu.dev/docs/api-reference) › [@evolu/common](https://evolu.dev/docs/api-reference/common) › [Cache](https://evolu.dev/docs/api-reference/common/Cache) › createLruCache

```ts
function createLruCache<K, V>(
  capacity: number & Brand<"Int"> & Brand<"NonNegative"> & Brand<"Positive">,
): Cache<K, V>;
```

Defined in: [packages/common/src/Cache.ts:53](https://github.com/evoluhq/evolu/blob/e7144e2bbe9069362b62dec1b64a8aa922b8f1b0/packages/common/src/Cache.ts#L53)

Creates an LRU (least recently used) cache with a maximum capacity.

When the cache reaches capacity, the least recently used entry is evicted.
Both `get` and `set` operations update the access order.

### Example

```ts
const cache = createLruCache<string, number>(2);
cache.set("a", 1);
cache.set("b", 2);
cache.set("c", 3); // Evicts "a"
cache.has("a"); // false
```