mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
* API: Compute schema once and share among other nodes From #23328 * Compute schema once and share among other nodes * Add compress/decompress * Remove weirdness * Make timeout configurable * Remove compression/decompression This was putting back the issues again. I guess it's because the transformation to async It seems useBus is already doing compression So I believe there's no need for double compression. * Add changeset --------- Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com> * Fix formatting issue --------- Co-authored-by: José Varela <varela@directus.io>
@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,
});