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

mikro-orm-cache-adapter-redis

Package Overview
Dependencies
Maintainers
0
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mikro-orm-cache-adapter-redis

A redis cache adapter for mikro-orm

  • 4.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
268
decreased by-3.6%
Maintainers
0
Weekly downloads
 
Created
Source

Mikro-orm - Redis cache adapter

This is an adapter for redis to be used with mikro-orm.

Install it with its peer dependencies

npm i mikro-orm-cache-adapter-redis ioredis

and pass it as option to mikro-orm

import { MikroORM } from '@mikro-orm/core/MikroORM';
import { RedisCacheAdapter } from 'mikro-orm-cache-adapter-redis';

const orm = await MikroORM.init({
  // Your options
  resultCache: {
    adapter: RedisCacheAdapter,
    options: {
      // Base options
      // An optional key prefix. By default is `mikro`
      keyPrefix: 'mikro'
      // Optional: print debug informations
      debug: false,


      // Here goes IORedis connection options (the library will instantiate the client)
      host: '...',
      port: 6379,
      password: 'yourpassword'
    }
  }
});

Instead of passing options, you can pass directly an IORedis instance

import { RedisCacheAdapter } from "mikro-orm-cache-adapter-redis";
import Redis from "ioredis";

const myRedisClient = new Redis();

const orm = await MikroORM.init({
  // Your options
  resultCache: {
    adapter: RedisCacheAdapter,
    options: {
      client: myRedisClient,
    },
  },
});

Serializing

This package uses serialize and deserialize functions from the Node.js v8 API instead of JSON.stringify and JSON.parse.

They are inadequate for certain primitive data types like Buffer and Typed Array, as they cannot accurately reproduce same data after serialization. You can checkout its limitation here.

But, there're still some primitives that serialize cannot handle.

  • function
  • symbol
  • any uncopyable data

If you need to serialize these types of data, you should using a custom serializer or custom type

If you're in debug mode, you will see JSON stringified data at your console. This is solely for debugging purposes. serialize is used for actual cache.

FAQs

Package last updated on 17 Aug 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