Files
Rijk van Zanten 7d2310badd Finish dependency move (#25583)
* Dangerously update API deps

* Dangerously move app dependencies to pnpm-workspace

* Move all dependencies to catalog

* Sort catalog

* Pnpm update

* Use pnpm 10.14

* Update for zod breaking change

* Fix unhead breaking change

* Downgrade major api upgrades

* Downgrade app major upgrades

* Fix app tests

* Downgrade isolated-vm

* Add changeset

* Fix template in head

* Resolve unhead lang signature

* Downgrade unhead

* Downgrade keyv/redis

It uses a different redis lib under the hood which is incompatible

* Resolve import in test

* Update and move workspace root dependencies

* Update CSS for updated linter rules

* Oops

* Run formatter

* Update rule name

* Run prettier

* Move utils peer to catalog

* Add focus-trap dependency
2025-08-04 18:13:12 -04:00
..
2025-01-02 15:37:30 +01:00
2025-08-04 18:13:12 -04:00
2023-12-21 14:08:42 -05:00

@directus/memory

Directus has various different needs for ephemeral storage that's synced between multiple processes for the same Directus Projects. To streamline that setup, this package exports three classes that are used for everything related to ephemeral storage:

Kv

The Kv class is a simple key-value store

Basic Usage

import { createKv } from '@directus/memory';

const cache = createKv({
	type: 'memory',
});

await cache.set('my-key', 'my-value');

Cache

The cache class is a Kv class extended with an LRU store

Basic Usage

import { createCache } from '@directus/memory';

const cache = createCache({
	type: 'memory',
	maxKeys: 500,
});

await cache.set('my-key', 'my-value');

Bus

The bus class is a pub-sub abstraction. The memory type bus just handles local handlers, which adds no benefit next to having a shared API for using pubsub.

Basic Usage

import { Redis } from 'ioredis';
import { createBus } from '@directus/memory';

const bus = createBus({
	type: 'redis',
	redis: new Redis(),
	namespace: 'directus',
});

Limiter

The limiter class is a basic shared rate limiter.

Basic Usage

import { createLimiter } from '@directus/memory';

const limiter = createLimiter({
	type: 'memory',
	points: 10,
	duration: 5,
});