Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@directus/memory

Package Overview
Dependencies
Maintainers
2
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@directus/memory

Memory / Redis abstraction for Directus

  • 2.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.6K
decreased by-50.66%
Maintainers
2
Weekly downloads
 
Created
Source

@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
  • Bus
  • Limiter

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,
});

FAQs

Package last updated on 03 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc