h5p-redis-lock
This package provides a lock mechanism that can be used if the library runs in multi-process or cluster-mode. The locks are needed to avoid race conditions when installing libraries.
1
import ioredis from 'ioredis-mock';
2
import { H5PEditor, H5PPlayer } from '@lumieducation/h5p-server';
3
import RedisLockProvider from '@lumieducation/h5p-redis-lock';
4
5
// Create a regular ioredis connection
6
const redis = new ioredis(redisPort, redisHost, { db: redisDb });
7
8
// Create the lock provider
9
const lockProvider = new RedisLockProvider(redis);
10
11
// Pass it to the editor and player object
12
const h5pEditor = new H5PEditor( /*other parameters*/, options: { lockProvider } );
13
const h5pPlayer = new H5PPlayer( /*other parameters*/, options: { lockProvider } );
Copied!
It is important to make sure that all instances of H5PEditor use a redis lock provider that points to the same database. Otherwise race conditions can happen.
Last modified 21d ago
Copy link