Files
directus/packages/memory
dependabot[bot] 9549fae231 Bump @types/node from 18.16.12 to 18.19.3 (#20777)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 18.16.12 to 18.19.3.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-18 02:42:45 +01:00
..
2023-12-13 11:29:22 -05:00
2023-12-13 11:29:22 -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:

Cache

The cache class is a LRU-based key-value 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,
});